如果一个用户test获取了一下权限:grant connect,resource,dba to test;
那么建它下的某个表A的trigger,要求system用户的表B存(存取全部或部分)A表的同步数据
请问test用户还需要获取那些权限!
有人说有DBA,权限了完全可以创建了!
但是我在test用户创建system用户的表B时show errors时提示:表或试图不存在?
请问不是权限的问题是什么问题?

解决方案 »

  1.   

    select * from system.表名!
      

  2.   

    Oracle 存储过程(触发器是存储过程的一种)默认使用authid definer定义者权限,而该权限模型下不继承任何角色授权(比如说DBA角色),任何需要的角色特权需要显式授予调用者,这里就是需要将create any table权限授予test 用户.不过,将用户数据创建在system schema下可不是个好主意.
      

  3.   

    将create any table权限授予test 用户也不行,还是出现表或试图不存在
      

  4.   

    你在trigger里干了什么事,就要先grant相应权限.比如你要select某些表,则
    grant select any table to test;
    或grant select on xxxtable to test;如果你要delete,则:
    grant select on xxxtable to test;
      

  5.   

    〖原理(Cause)〗
    DML(delete/update/insert)触发器中不能使用DDL(CREATE,DROP,ALTER)语句,也不能使用事务控制语句(ROLLBACK, COMMIT,SAVEPOINT)。特别注意的是,在触发器的主体中引用的函数(function)/过程(procedure)中也不能有事物控制语句。〖小贴士(Tip)〗
    系统级触发器(System Triggers)中可以使用DDL语句。
     
    〖方法(Action)〗
     去掉事务控制语句,或使用自治事务(autonomous transactions)完成DDL以及其它引起隐性提交当前事务的操作
    All Data Definition Language (DDL) statements execute an implicit commit.
    Even if you create a separate procedure, to execute the DDL statement, the 
    execution of the separate procedure within the trigger is still in the same 
    transaction, forcing a commit of any statement executed in the trigger and 
    hence causing the error ORA-04092.Use autonomous transactions to create the table:1) Create a procedure called my_procedure that will execute as an autonomous 
    transaction:SQL> create or replace procedure my_procedure
    2 is
    3 pragma AUTONOMOUS_TRANSACTION;
    4 BEGIN
    5 execute immediate 'CREATE TABLE my_table (id NUMBER)';
    6 END;
    7 /Procedure created.2) Create the trigger, that will call the autonomous procedure to create the 
    table:SQL> create or replace trigger my_trig after delete on emp
    2 BEGIN
    3 my_procedure;
    4 END;
    5 /Trigger created.
      

  6.   

    我觉的你要在test用户下访问system下面的表,就算附了权限,要查询system下面的表的话,也应该叫个system.表名吧,除非建了别名