模拟MySQL的show grants命令
首先创建用户,并且将示例帐号的表授权给他。
- sqlplus / as sysdba
- drop user edmond cascade;
- create user edmond identified by edmond;
- grant connect,resource to edmond;
- grant select,insert,update,delete on hr.employees to edmond;
- grant update(department_id),insert(department_name,department_id) on hr.departments to edmond;
作为DBA帐号登录,查看他的权限。
- set linesize 200;
- col privs_type format a10;
- col username format a20;
- col table_name format a35;
- col column_name format a25;
- col PRIVILEGE format a60;
- with t1 as
- (
- select upper("edmond") username from dual
- )
- select "角色" privs_type,"NULL" username,"NULL" table_name,"NULL" column_name,wm_concat(GRANTED_ROLE) PRIVILEGE from dba_role_privs,t1 where GRANTEE=t1.username group by "角色","NULL","NULL","NULL"
- union all
- select "表权限",owner,TABLE_NAME,"NULL",wm_concat(PRIVILEGE) PRIVILEGE from dba_tab_privs,t1 where GRANTEE=t1.username group by "表权限",owner,TABLE_NAME,"NULL"
- union all
- select "列权限",owner,TABLE_NAME,column_name,wm_concat(PRIVILEGE) PRIVILEGE from dba_col_privs,t1 where GRANTEE=t1.username group by "列权限",owner,TABLE_NAME,column_name;
作为普通用户登录,查看权限
- set linesize 200;
- col privs_type format a10;
- col username format a20;
- col table_name format a35;
- col column_name format a25;
- col PRIVILEGE format a60;
- with t1 as
- (
- select upper("edmond") username from dual
- )
- select "表权限" privs_type,TABLE_SCHEMA username,TABLE_NAME,"NULL" column_name,wm_concat(PRIVILEGE) PRIVILEGE from all_tab_privs,t1 where GRANTEE=t1.username group by "表权限",TABLE_SCHEMA,TABLE_NAME,"NULL"
- union all
- select "列权限",TABLE_SCHEMA,TABLE_NAME,column_name,wm_concat(PRIVILEGE) PRIVILEGE from all_col_privs,t1 where GRANTEE=t1.username group by "列权限",TABLE_SCHEMA,TABLE_NAME,column_name;
--------------------------------------------------------------------------------Linux-6-64下安装Oracle 12C笔记 http://www.linuxidc.com/Linux/2013-07/86805.htm在CentOS 6.4下安装Oracle 11gR2(x64) http://www.linuxidc.com/Linux/2014-02/97374.htmOracle 11gR2 在VMWare虚拟机中安装步骤 http://www.linuxidc.com/Linux/2013-09/89579p2.htmDebian 下 安装 Oracle 11g XE R2 http://www.linuxidc.com/Linux/2014-03/98881.htm--------------------------------------------------------------------------------更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
本文永久更新链接地址