溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled

發(fā)布時間:2020-09-29 19:02:03 來源:網(wǎng)絡(luò) 閱讀:625 作者:sugar黑黑 欄目:關(guān)系型數(shù)據(jù)庫

今天新建數(shù)據(jù)庫使用hr用戶練習(xí)的時候,set autotrace on時出現(xiàn)以下錯誤

SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled

是因為沒有PLUSTRACE權(quán)限

涉及到@ORACLE_HOME/sqlplus/admin/plustrce.sql文件

內(nèi)容如下

-- DESCRIPTION
--   Creates a role with access to Dynamic Performance Tables
--   for the SQL*Plus SET AUTOTRACE ... STATISTICS command.
--   After this script has been run, each user requiring access to
--   the AUTOTRACE feature should be granted the PLUSTRACE role by
--   the DBA.
--
-- USAGE
--   sqlplus "sys/knl_test7 as sysdba" @plustrce
--
--   Catalog.sql must have been run before this file is run.
--   This file must be run while connected to a DBA schema.

set echo on

drop role plustrace;
create role plustrace;

grant select on v_$sesstat to plustrace;
grant select on v_$statname to plustrace;
grant select on v_$mystat to plustrace;
grant plustrace to dba with admin option;

set echo off

1.  查找數(shù)據(jù)庫中是否有該角色

SQL> select * from dba_roles where role='PLUSTRACE';  

no rows selected

 2.建立角色  (使用sys用戶)

SQL> @?/sqlplus/admin/plustrce.sql
SQL> 
SQL> drop role plustrace;
drop role plustrace
          *
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not exist


SQL> create role plustrace;

Role created.

SQL> 
SQL> grant select on v_$sesstat to plustrace;

Grant succeeded.

SQL> grant select on v_$statname to plustrace;

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

3.查詢數(shù)據(jù)庫

SQL> select * from dba_roles where role='PLUSTRACE';

ROLE			       PASSWORD AUTHENTICAT
------------------------------ -------- -----------
PLUSTRACE		       NO	NONE

4.授予操作用戶改權(quán)限

SQL> grant plustrace to hr;

Grant succeeded.

5.使用hr用戶測試是否成功

SQL> conn hr/hr
Connected.
SQL> 
SQL> set autotrace on


向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI