1. 程式人生 > >oracle中怎樣讓一個用戶查詢其它用戶的trigger?

oracle中怎樣讓一個用戶查詢其它用戶的trigger?

TP lec 其他 1.2 cee copy IT edit ola

在工作期間,有時候遇到這種需求,需要將一個用戶下的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>

oracle中怎樣讓一個用戶查詢其它用戶的trigger?