先创建plan_table 表
SQL>@%oracle_home%/rdbms/admin/utlxplan.sql
授权
SQL>@%oracle_home%/sqlplus/admin/plustrce.sql
这样普通用户不能用
所以要授权普通用户对 plan_table 表
SQL>conn / as sysdba
SQL>create public synonym plan_table for plan_table;
SQL>grant all on plan_table to public;
开启查询计划
SQL>set autotrace on --显示执行计划和统计信息
SQL>set autotrace on explain --只显示执行计划
SQL>set autotrace on statistics --只显示统计信息
SQL>set autotrace traceonly --同autotrace on,但不显示查询结果
SQL>set autotrace off --关闭autotrace