Home  >  Article  >  Database  >  Oracle用户权限 -- 新建用户权限继承另一用户的权限

Oracle用户权限 -- 新建用户权限继承另一用户的权限

WBOY
WBOYOriginal
2016-06-07 17:06:211660browse

题记:今天要为监控服务器I2000在现网数据库中新建用户,要求该用户的权限与数据库已经存在的某一用户的权限一致!这里提供了我的

题记:今天要为监控服务器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');
然后将上面打印在屏幕上的拷贝执行就可以了。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn