Oracle使用者權限 -- 建立使用者權限繼承另一使用者的許可權

來源:互聯網
上載者:User

題記:今天要為監控伺服器I2000在現網資料庫中建立使用者,要求該使用者的許可權與資料庫已經存在的某一使用者的許可權一致!這裡提供了我的做法,方法應該不是很好,不知道哪位大俠有更好的方法,希望給予指教,謝謝!

實驗:
要求:建立使用者i2ksnmp的許可權要和資料庫已經存在的DBSNMP使用者的許可權一樣。
1. 建立新使用者i2ksnmp
create user i2ksnmp identified by i2ksnmp;

2. 查看DBSNMP使用者的所有系統許可權
select privilege from dba_sys_privs where grantee='DBSNMP' 
union 
select privilege from dba_sys_privs where grantee in (select granted_role from dba_role_privs where grantee='DBSNMP' );
如下,得到DBSNMP使用者的所有系統許可權:
PRIVILEGE
----------------------------------------
ADVISOR
ANALYZE ANY
ANALYZE ANY DICTIONARY
CREATE JOB
CREATE PROCEDURE
CREATE SESSION
CREATE TABLE
MANAGE ANY QUEUE
SELECT ANY DICTIONARY
UNLIMITED TABLESPACE

3. 然後將上面的許可權都賦予建立使用者即可
比如:
grant ANALYZE ANY DICTIONARY to i2ksnmp;

附加:
這裡簡單的整合了上面的方法:
set feedback off heading off verify off trimspool off
set pagesize 0 linesize 200
define user=test   ---> 這裡是建立使用者名稱
select 'grant  '||privilege||'  to &user;' from dba_sys_privs where grantee = 'DBSNMP'
union 
select 'grant  '||privilege||'  to &user;' from dba_sys_privs where grantee in (select granted_role from dba_role_privs where grantee = 'DBSNMP');
然後將上面列印在螢幕上的拷貝執行就可以了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.