其它(Role & User & Privilege)

简介: 一、授予权限 GRANT privilege [, ...] ON object [, ...] TO {PUBLIC | GROUP group | username} 二、撤销权限 REVOKE |[()] [ON ] FROM | [CASCADE CONSTRAINTS]; --如果要删除通过 REFERENCES 权限对该对象实行的任何引用完整性约束,则此选项是必须的。

一、授予权限

GRANT privilege [, ...] ON object [, ...] TO {PUBLIC | GROUP group | username}

二、撤销权限

REVOKE <priv_name>|<role_name>[(<coloumn_name>)] [ON <table_name>] 
FROM <role_name>|<user_name> 
[CASCADE CONSTRAINTS];    --如果要删除通过 REFERENCES 权限对该对象实行的任何引用完整性约束,则此选项是必须的。

注:如果用户是通过 WITH GRANT OPTION 子句获得某项权限,则该用户也可以用 WITH GRANT OPTION 子句授予其他用户权限,这样就可能出现一长串的被授予者,但不允许循环授予权限。如果所有者从用户处撤消了某项权限,而该用户将此权限授予了其他用户,则撤销操作会级联到所有授予的权限。

对于WITH ADMIN OPTION的系统权限,父权限回收,子权限将不级连回收

对于WITH GRANT OPTION的对象权限,父权限回收,子权限将级连回收

三、查看USER创建信息

SELECT A.USERNAME,
       A.DEFAULT_TABLESPACE,
       A.TEMPORARY_TABLESPACE,
       TO_CHAR(A.CREATED, 'yyyy-mm-dd hh24:mi:ss'),
       A.PROFILE
  FROM DBA_USERS A
 WHERE USERNAME = '';

SELECT * FROM DBA_TS_QUOTAS A;

四、查看用户状态信息

SELECT A.USERNAME,
       A.ACCOUNT_STATUS,
       TO_CHAR(A.LOCK_DATE, 'yyyy-mm-dd hh24:mi:ss'),
       TO_CHAR(A.EXPIRY_DATE, 'yyyy-mm-dd hh24:mi:ss')
  FROM DBA_USERS A;

五、查看 profile 内容 

SELECT * FROM DBA_PROFILES WHERE PROFILE = 'PF_EAGLE';

六、获取用户创建语句 

SELECT DBMS_METADATA.GET_DDL('USER', 'SCOTT')
  FROM DUAL
 UNION ALL
SELECT DBMS_METADATA.GET_GRANTED_DDL('SYSTEM_GRANT', 'SCOTT')
  FROM DUAL
 UNION ALL
SELECT DBMS_METADATA.GET_GRANTED_DDL('OBJECT_GRANT', 'SCOTT')
  FROM DUAL
 UNION ALL
SELECT DBMS_METADATA.GET_GRANTED_DDL('ROLE_GRANT', 'SCOTT')
  FROM DUAL;

目录
相关文章
|
6月前
Why Account Status Is Open When Expiry Date is Old Date in DBA_USERS
Why Account Status Is Open When Expiry Date is Old Date in DBA_USERS
47 0
EnvironmentNotWritableError: The current user does not have write permissions to the targe...
EnvironmentNotWritableError: The current user does not have write permissions to the targe...
1896 0
|
6月前
Example: Auditing the SYS User
Example: Auditing the SYS User
24 0
|
SQL 关系型数据库 MySQL
MySQL中USER()和CURRENT_USER()的区别
USER()和CURRENT_USER()的一点不同
145 0
|
关系型数据库 数据库 PostgreSQL
postgresql :ERROR: role “user001“ cannot be dropped because some objects depend on it
postgresql :ERROR: role “user001“ cannot be dropped because some objects depend on it
884 0
|
SQL 关系型数据库 MySQL
Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT
Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT
|
NoSQL Redis Sentinel
ROLE
1259 0
|
SQL 测试技术 数据库
0131 ORA-00942 and AUTHID CURRENT_USER
[20180131]ORA-00942 and AUTHID CURRENT_USER.txt --//偶尔写一个存储过程调用一些系统视图.经常遇到一些ORA-00942,有时候很烦.
1155 0
|
JavaScript 关系型数据库 MySQL