老是忘记如何设置SQLPlus的autotrace,特此记录一篇

验证是否设置plustrace的最简单方法就是找个用户执行一下 set autotrace on,如果报错如下:

firewall@FWDB SQL> set autotrace on ; 
SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report

就表示没有设置好:

跑一下以下这段脚本就可以了

sys@ora10g(oracle01) SQL> @?/sqlplus/admin/plustrce;
sys@ora10g(oracle01) SQL> grant plustrace to public;

其实普通用户愿意查看一下自己写的SQL的执行计划是一件好事,将plustrace赋予给所有人也不是什么坏事。

几种用法:

set autotrace off
set autotrace on explain
set autotrace on statistics
set autotrace on 
原文地址:https://www.cnblogs.com/killkill/p/1611127.html