程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> ORACLE管理-查看擁有DBA角色的用戶

ORACLE管理-查看擁有DBA角色的用戶

編輯:Oracle教程

ORACLE管理-查看擁有DBA角色的用戶


1.查看所有用戶:
  select * from dba_users;
  select * from all_users;
  select * from user_users;
2.查看用戶或角色系統權限(直接賦值給用戶或角色的系統權限):
	select * from dba_sys_privs;
  select * from user_sys_privs;
SQL> select * from user_sys_privs;

USERNAME                       PRIVILEGE                                ADM
------------------------------ ---------------------------------------- ---
ZSZQ                           UNLIMITED TABLESPACE                     NO
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;
--查詢擁有DBA權限的用戶
SQL> select * from dba_role_privs where granted_role='DBA';

GRANTEE                        GRANTED_ROLE                   ADM DEF
------------------------------ ------------------------------ --- ---
SYS                            DBA                            YES YES
SYSTEM                         DBA                            YES YES
ZSZQ                           DBA                            NO  YES
KSWORK

7.查看哪些用戶有sysdba或sysoper系統權限(查詢時需要相應權限)

select * from V$PWFILE_USERS
比如我要查看用戶 wzsb的擁有的角色: 


SQL> select * from dba_sys_privs where grantee='ZSZQ';

GRANTEE                        PRIVILEGE                                ADM
------------------------------ ---------------------------------------- ---
ZSZQ                           UNLIMITED TABLESPACE                     NO

查看一個用戶所有的權限及角色
select privilege
  from dba_sys_privs
 where grantee = 'ZSZQ'
union
select privilege
  from dba_sys_privs
 where grantee in      
       (select granted_role from dba_role_privs where grantee = 'ZSZQ');


SQL> select * from dba_sys_privs where grantee='ZSZQ';

GRANTEE                        PRIVILEGE                                ADM
------------------------------ ---------------------------------------- ---
ZSZQ                           UNLIMITED TABLESPACE                     NO
8、查看RESOURCE具有那些權限 
SQL> SELECT * FROM DBA_SYS_PRIVS WHERE GRANTEE='RESOURCE';
GRANTEE                        PRIVILEGE                                ADM
------------------------------ ---------------------------------------- ---
RESOURCE                       CREATE TRIGGER                           NO
RESOURCE                       CREATE SEQUENCE                          NO
RESOURCE                       CREATE TYPE                              NO
RESOURCE                       CREATE PROCEDURE                         NO
RESOURCE                       CREATE CLUSTER                           NO
RESOURCE                       CREATE OPERATOR                          NO
RESOURCE                       CREATE INDEXTYPE                         NO
RESOURCE                       CREATE TABLE                             NO

已選擇8行。

SQL> select * from role_sys_privs t1 where t1.role = 'RESOURCE';

ROLE                           PRIVILEGE                                ADM
------------------------------ ---------------------------------------- ---
RESOURCE                       CREATE SEQUENCE                          NO
RESOURCE                       CREATE TRIGGER                           NO
RESOURCE                       CREATE CLUSTER                           NO
RESOURCE                       CREATE PROCEDURE                         NO
RESOURCE                       CREATE TYPE                              NO
RESOURCE                       CREATE OPERATOR                          NO
RESOURCE                       CREATE TABLE                             NO
RESOURCE                       CREATE INDEXTYPE                         NO

已選擇8行。

9.查看scott用戶的默認表空間、臨時表空間
select username, default_tablespace, temporary_tablespace
  from dba_users
 where username = 'SCOTT';
10.查看scott用戶的系統權限
select username,privilege,admin_option 
from user_sys_privs 
where username = 'SCOTT';

SQL> select username,privilege,admin_option
  2  from user_sys_privs
  3  where username = 'SCOTT';

USERNAME                       PRIVILEGE                                ADM
------------------------------ ---------------------------------------- ---
SCOTT                          CREATE VIEW                              NO
SCOTT                          UNLIMITED TABLESPACE                     NO

11.查看賦予scott用戶的對象權限
select grantee,owner, table_name, t.grantor, t.privilege, t.grantable, t.hierarchy
from dba_tab_privs t
where t.grantee = 'SCOTT'; 
12.查看授予了scott的角色權限
select t.grantee, t.granted_role, t.admin_option, t.default_role
  from dba_role_privs t
 where t.grantee = 'SCOTT';

SQL> select t.grantee, t.granted_role, t.admin_option, t.default_role
  2    from dba_role_privs t
  3   where t.grantee = 'SCOTT';

GRANTEE                        GRANTED_ROLE                   ADM DEF
------------------------------ ------------------------------ --- ---
SCOTT                          RESOURCE                       NO  YES
SCOTT                          CONNECT                        NO  YES

SQL> select * from user_role_privs t;

USERNAME                       GRANTED_ROLE                   ADM DEF OS_
------------------------------ ------------------------------ --- --- ---
ZSZQ                           CONNECT                        NO  YES NO
ZSZQ                           DBA                            NO  YES NO
ZSZQ                           EXP_FULL_DATABASE              NO  YES NO
ZSZQ                           IMP_FULL_DATABASE              NO  YES NO
ZSZQ                           RESOURCE                       NO  YES NO

13.查看scott用戶使用了哪些表空間
select t.table_name, t.tablespace_name
from  dba_all_tables t
where t.owner = 'SCOTT' ;
14.查看當前用戶擁有的權限
select t.privilege from session_privs t;

SQL> select t.privilege from session_privs t;

PRIVILEGE
----------------------------------------
CREATE SESSION
UNLIMITED TABLESPACE
CREATE TABLE
CREATE CLUSTER
CREATE VIEW
CREATE SEQUENCE
CREATE PROCEDURE
CREATE TRIGGER
CREATE TYPE
CREATE OPERATOR
CREATE INDEXTYPE

已選擇11行。

14.查看角色(DBA)被賦予的角色權限
select * from role_role_privs t where t.role = 'DBA';
查看角色(DBA)被賦予的對象權限
15.select * from role_tab_privs t1  where t1.role = 'DBA'

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved