查看執行計劃的方法:sql
1:set autotrace onit
若是出現錯誤:須要重建plustrce角色;io
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing optionstable
SQL> @?/sqlplus/admin/plustrce.sql
SQL>
SQL> drop role plustrace;
drop role plustrace
*
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not existselect
SQL> create role plustrace;方法
Role created.統計
SQL>
SQL> grant select on v_$sesstat to plustrace;db
Grant succeeded.tab
SQL> grant select on v_$statname to plustrace;di
Grant succeeded.
SQL> grant select on v_$mystat to plustrace;
Grant succeeded.
SQL> grant plustrace to dba with admin option;
Grant succeeded.
SQL>
SQL> set echo off
SQL>
SQL> drop role plustrce;
drop role plustrce
*
ERROR at line 1:
ORA-01919: role 'PLUSTRCE' does not exist
SQL> create role plustrce;
Role created.
SQL> grant select on v_$sesstat to plustrce;
Grant succeeded.
SQL> grant select on v_$statname to plustrce;
Grant succeeded.
SQL> grant select on v_$mystat to plustrce;
Grant succeeded.
SQL> grant plustrce to dba with admin option;
Grant succeeded.
SQL> set echo off
SQL> grant plustrce to scott;
Grant succeeded.
set autotrace on/off 【開啓關閉】
set autotrace explain/statistics 【只顯示執行計劃/只顯示統計信息】
set autotrace traceonly 【顯示統計信息和執行計劃,可是不顯示執行結果】
2:explain plan for SQL;
select * from table(dbms_xplan.diaplay);
select plan_table_output from table(dbms_xplan.display('plan_table'));
3:10046