首页 > 代码库 > oracle 用户权限相关

oracle 用户权限相关

--查看数据库下的所有用户:

select username from dba_users;

--查看当前连接数据库的用户角色

SELECT * FROM USER_ROLE_PRIVS;

-- 创建用户

CREATE user test identified by test;

-- 赋授权

grant connect,resource to test; --赋给只允许连接查看的权限grant connect,resource to test; --赋给普通权限  开发运维基本已经满足grant connect,resource to test; --赋给管理员权限

--查询某个角色中具有什么系统权限:

select privilege from role_sys_privs where role=RESOURCE;PRIVILEGE----------------------------------------CREATE SEQUENCECREATE TRIGGERCREATE CLUSTERCREATE PROCEDURECREATE TYPECREATE OPERATORCREATE TABLECREATE INDEXTYPE8 rows selected.

--查询某个角色中包含有什么角色 --如果不包含其他角色,查询结果为空。

select granted_role from role_role_privs where role=dba;

-- 若用户锁定给用户解锁

alter user test account unlock;

--查看某个用户的权限 --注意:11g 用户名 默认区分大小写

select grantee,granted_role from dba_role_privs where grantee=test;GRANTEE GRANTED_ROLE------------------------------ ------------------------------test    IMP_FULL_DATABASEtest EXP_FULL_DATABASEtest CONNECTtest    RESOURCE

-- 查看指定用户的系统权限

SELECT *FROM DBA_SYS_PRIVSWHERE GRANTEE = testUNION ALLSELECT *FROM DBA_SYS_PRIVSWHERE GRANTEE IN(SELECT GRANTED_ROLE FROM DBA_ROLE_PRIVS WHERE GRANTEE = test);

-- 查看当前连接数据库用户的 对象权限

SELECT *FROM DBA_TAB_PRIVSWHERE GRANTEE = testUNION ALLSELECT *FROM DBA_TAB_PRIVSWHERE GRANTEE IN(SELECT GRANTED_ROLE FROM DBA_ROLE_PRIVS WHERE GRANTEE = test);


oracle 用户权限相关