二十五、SET AUTOTRACE ON 報 CAN NOT SET AUTOTRACE ON錯誤
阿新 • • 發佈:2018-12-10
SET AUTOTRACE ON 報 CAN NOT SET AUTOTRACE ON錯誤
以下操作建議在sqlPlus中執行。
1、建立plan表
登陸sys使用者,並執行utlxplan.sql指令碼,建立plan表
SQL> @F:\OracleServerAndClinet\Server\app\yang\product\11.2.0\dbhome_1\RDBMS\ADMIN\utlxplan.sql
Table created
2、建立plustrace角色
還是在sys使用者下,執行plustrce.sql指令碼,資料庫啟用autotrace功能的安裝指令碼,主要是建立plustrace角色,並且授權 ,擁有plustrace最主要的目的是為了訪問下面幾個VIEW :
v_$sesstat;
v_$statname;
v_$mystat;
SQL> @F:\OracleServerAndClinet\Server\app\yang\product\11.2.0\dbhome_1\sqlplus\admin\plustrce.sql drop role plustrace; drop role plustrace ORA-01919: 角色 'PLUSTRACE' 不存在 create role plustrace; Role created grant select on v_$sesstat to plustrace; Grant succeeded grant select on v_$statname to plustrace; Grant succeeded grant select on v_$mystat to plustrace; Grant succeeded grant plustrace to dba with admin option; Grant succeeded set echo off
3、plustrace角色授予使用者
SQL> grant plustrace to scott;
Grant succeeded
SQL> grant all on plan_table to scott;
Grant succeeded
4、設定自動追蹤
set timing on #顯示執行SQL操作的時間
set linesize 1000 #輸出一行字元個數為100
set autotrace on #設定自動追蹤