SQL> edit
已写入文件 afiedt.buf
1 select a.ename, b.dname, c.job
2 from emp a,dept b,bonus c
3* where a.deptno=b.deptno and a.job=c.job
SQL> set autotrace on;
SQL> /
未选定行
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 NESTED LOOPS
2 1 MERGE JOIN
3 2 SORT (JOIN)
4 3 TABLE ACCESS (FULL) OF 'BONUS'
5 2 SORT (JOIN)
6 5 TABLE ACCESS (FULL) OF 'EMP'
7 1 TABLE ACCESS (BY INDEX ROWID) OF 'DEPT'
8 7 INDEX (UNIQUE SCAN) OF 'PK_DEPT' (UNIQUE)
Statistics
----------------------------------------------------------
106 recursive calls
0 db block gets
31 consistent gets
1 physical reads
0 redo size
322 bytes sent via SQL*Net to client
372 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
0 rows processed
SQL> edit
已写入文件 afiedt.buf
1 select /*+ordered*/a.ename, b.dname, c.job
2 from emp a,dept b,bonus c
3* where a.deptno=b.deptno and a.job=c.job
SQL> /
未选定行
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=8 Card=82 Bytes=4428
)
1 0 HASH JOIN (Cost=8 Card=82 Bytes=4428)
2 1 HASH JOIN (Cost=5 Card=82 Bytes=3936)
3 2 TABLE ACCESS (FULL) OF 'EMP' (Cost=2 Card=82 Bytes=213
2)
4 2 TABLE ACCESS (FULL) OF 'DEPT' (Cost=2 Card=82 Bytes=18
04)
5 1 TABLE ACCESS (FULL) OF 'BONUS' (Cost=2 Card=82 Bytes=492
)
Statistics
----------------------------------------------------------
122 recursive calls
0 db block gets
22 consistent gets
3 physical reads
0 redo size
322 bytes sent via SQL*Net to client
372 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processed
具体访问表的顺序 看的稀里糊涂 先后的顺序应该是 第一种情况(8-7-6-5-4-3-2-1-0) dept-emp-bonus 第二种情况 (5-4-3-2-1-0) bonus-dept-emp