a 查看用户、权限、角色的适用命令
1.查看所有用户:
select * from dba_users;
select * from all_users;
select * from user_users;
2.查看用户系统权限:
select * from dba_sys_privs;
select * from session_privs;
select * from user_sys_privs;
3.查看用户对象权限:
select * from dba_tab_privs;
select * from all_tab_privs;
select * from user_tab_privs;
4.查看所有角色:
select * from dba_roles;
5.查看用户所拥有的角色:
select * from dba_role_privs;
select * from user_role_privs;
b 与权限,角色相关的视图大概有下面这些:
DBA_SYS_PRIVS: 查询某个用户所拥有的系统权限
USER_SYS_PRIVS: 查询当前用户所拥有的系统权限
SESSION_PRIVS: 查询当前用户所拥有的全部权限
ROLE_SYS_PRIVS: 查询某个角色所拥有的系统权限 注意: 要以 SYS 用户登陆查询这个视图,否则返回空.
ROLE_ROLE_PRIVS: 当前角色被赋予的角色
SESSION_ROLES: 当前用户被激活的角色
USER_ROLE_PRIVS: 当前用户被授予的角色
关于创建视图权限不足时,可以在dos下用sqlplus /@orcl as sysdba登录到Oracle,再给所需要的用户赋予权限:grant create view to scott;再用pl/sql以scott登录时就可以创建视图了。
关于scott用户的解锁命令:alter user scott account unlock
1.查看所有用户:
select * from dba_users;
select * from all_users;
select * from user_users;
2.查看用户或角色系统权限(直接赋值给用户或角色的系统权限):
select * from dba_sys_privs;
select * from user_sys_privs;
3.查看角色(只能查看登陆用户拥有的角色)所包含的权限
sql>select * from role_sys_privs;
4.查看用户对象权限:
select * from dba_tab_privs;
select * from all_tab_privs;
select * from user_tab_privs;
5.查看所有角色:
select * from dba_roles;
6.查看用户或角色所拥有的角色:
select * from dba_role_privs;
select * from user_role_privs;
7.查看哪些用户有sysdba或sysoper系统权限(查询时需要相应权限)
select * from V$PWFILE_USERS
比如我要查看用户 wzsb的拥有的权限:
SQL> select * from dba_sys_privs where grantee='WZSB';
GRANTEE PRIVILEGE ADMIN_OPTION
------------------------------ ---------------------------------------- ------------
WZSB CREATE TRIGGER NO
WZSB UNLIMITED TABLESPACE NO
比如我要查看用户 wzsb的拥有的角色:
SQL> select * from dba_role_privs where grantee='WZSB';
GRANTEE GRANTED_ROLE ADMIN_OPTION DEFAULT_ROLE
------------------------------ ------------------------------ ------------ ------------
WZSB DBA NO YES
查看一个用户所有的权限及角色
select privilege from dba_sys_privs where grantee='WZSB'
union
select privilege from dba_sys_privs where grantee in
(select granted_role from dba_role_privs where grantee='WZSB' );