码迷,mamicode.com
首页 > 数据库 > 详细

oracle中怎样让一个用户查询其它用户的trigger?

时间:2018-06-14 15:15:30      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:oracl   option   方法   base   data   bug   uri   copyright   nec   

在工作期间,有时候遇到这种需求,需要将一个用户下的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?

标签:oracl   option   方法   base   data   bug   uri   copyright   nec   

原文地址:https://www.cnblogs.com/erwadba/p/9182231.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!