題記:今天要為監(jiān)控服務(wù)器I2000在現(xiàn)網(wǎng)數(shù)據(jù)庫中新建用戶,要求該用戶的權(quán)限與數(shù)據(jù)庫已經(jīng)存在的某一用戶的權(quán)限一致!這里提供了我的
題記:今天要為監(jiān)控服務(wù)器I2000在現(xiàn)網(wǎng)數(shù)據(jù)庫中新建用戶,要求該用戶的權(quán)限與數(shù)據(jù)庫已經(jīng)存在的某一用戶的權(quán)限一致!這里提供了我的做法,方法應(yīng)該不是很好,不知道哪位大俠有更好的方法,希望給予指教,,謝謝!
實(shí)驗(yàn):
要求:新建用戶i2ksnmp的權(quán)限要和數(shù)據(jù)庫已經(jīng)存在的DBSNMP用戶的權(quán)限一樣。
1. 創(chuàng)建新用戶i2ksnmp
create user i2ksnmp identified by i2ksnmp;
2. 查看DBSNMP用戶的所有系統(tǒng)權(quán)限
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用戶的所有系統(tǒng)權(quán)限:
PRIVILEGE
----------------------------------------
ADVISOR
ANALYZE ANY
ANALYZE ANY DICTIONARY
CREATE JOB
CREATE PROCEDURE
CREATE SESSION
CREATE TABLE
MANAGE ANY QUEUE
SELECT ANY DICTIONARY
UNLIMITED TABLESPACE
3. 然后將上面的權(quán)限都賦予新建用戶即可
比如:
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');
然后將上面打印在屏幕上的拷貝執(zhí)行就可以了。
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com