--查看数据库下的所有用户:
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 SEQUENCE CREATE TRIGGER CREATE CLUSTER CREATE PROCEDURE CREATE TYPE CREATE OPERATOR CREATE TABLE CREATE INDEXTYPE 8 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_DATABASE test EXP_FULL_DATABASE test CONNECT test RESOURCE
-- 查看指定用户的系统权限
SELECT * FROM DBA_SYS_PRIVS WHERE GRANTEE = ‘test‘ UNION ALL SELECT * FROM DBA_SYS_PRIVS WHERE GRANTEE IN (SELECT GRANTED_ROLE FROM DBA_ROLE_PRIVS WHERE GRANTEE = ‘test‘);
-- 查看当前连接数据库用户的 对象权限
SELECT * FROM DBA_TAB_PRIVS WHERE GRANTEE = ‘test‘ UNION ALL SELECT * FROM DBA_TAB_PRIVS WHERE GRANTEE IN (SELECT GRANTED_ROLE FROM DBA_ROLE_PRIVS WHERE GRANTEE = ‘test‘);
时间: 2024-10-11 12:08:27