日期:2014-05-17  浏览次数:20843 次

详解两条T-SQL语句(如下)

--1.
select * from A,B where A.AID=B.BID and A.AID=1
--2.
select * from (select AID  from A where AID=1) as A1,B where A1.AID=B.BID

1.在任何情况下,上面两条T-SQL语句的执行结果是否相同?
2.详解上面两条T-SQL语句在什么情况下,执行效率问题?

------解决方案--------------------
select d.* from emp e,dept d where e.deptno=d.deptno and e.deptno=10;
执行计划如下:
执行计划
----------------------
Plan hash value: 568005898

----------------------------------------------------

------解决方案--------------------
 Id  
------解决方案--------------------
 Operation                    
------解决方案--------------------
 Name    
------解决方案--------------------
 Rows  
------解决方案--------------------
 Bytes 
------解决方案--------------------
 Cost (%CPU)
------解决方案--------------------
 Time     
------解决方案--------------------

----------------------------------------------------

------解决方案--------------------
   0 
------解决方案--------------------
 SELECT STATEMENT             
------解决方案--------------------
         
------解决方案--------------------
     5 
------解决方案--------------------
   110 
------解决方案--------------------
     4   (0)
------解决方案--------------------
 00:00:01 
------解决方案--------------------


------解决方案--------------------
   1 
------解决方案--------------------
  NESTED LOOPS                
------解决方案--------------------
         
------解决方案--------------------
     5 
------解决方案--------------------
   110 
------解决方案--------------------