在工作期间,有时候遇到这种需求,需要将一个用户下的trigger查询权限授予给其他的用户
怎样将某个用户的trigger查询权限,授予其他用户?
方法一:
授予 create any trigger权限。这个权限太大,一般都不会考虑将这种权限授予出去
方法二:
将表的bebug权限授予其他用户。这样就能查看到该用户表上的trigger了
测试:
[oracle@lxpcbsora2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 14 10:37:08 2018
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL> grant connect to erwa identified by erwa;
Grant succeeded.
SQL> select OWNER,TRIGGER_NAME from all_triggers where owner='SCOTT';
no rows selected
SQL>
在其他的会话创建一个trigger
[oracle@lxpcbsora2 ~]$ sqlplus scott/tiger
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 14 11:23:18 2018
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL> create or replace trigger test
2 before delete on emp
3 for each row
4 declare
5 -- local variables here
6 begin
7 dbms_output.put_line('test');
8 end test;
9 /
Trigger created.
SQL>
将表的debug权限授予erwa
SQL> grant debug on emp to erwa;
Grant succeeded.
SQL>
再次查询就可以看到scott下面新建立的trigger
SQL> show user
USER is "ERWA"
SQL> select OWNER,TRIGGER_NAME from all_triggers where owner='SCOTT';
OWNER TRIGGER_NAME
------------------------------ ------------------------------
SCOTT TEST
SQL>