Multi-Schema Privileges for a Table Trigger in an Oracle Database

后端 未结 3 1522
暗喜
暗喜 2021-01-19 11:03

I\'m trying to write a table trigger which queries another table that is outside the schema where the trigger will reside. Is this possible? It seems like I have no proble

3条回答
  •  失恋的感觉
    2021-01-19 11:39

    What you are experiencing is a feature of Oracle's security model. The entire point of using schemas is to control access to the data. The tables in my schema are mine, you cannot even see them until I grant you privileges on them.

    The syntax is quite simple: the owner schema issues

    grant select, insert on my_table to you
    /
    

    Alternatively an account with the GRANT ANY privilege (such as a DBA) can pass privileges on any user's objects.

    grant select, insert on apc.my_table to you
    /
    

    The grantee can be either a user or a role. However, note that we can only build program units - stored procedures, views, triggers - using privileges which have been granted directly through to our user.

    So, if you get the other schema owner to grant you the necessary privileges you will be able to build your trigger.

    edit

    When referencing an object in another schema we need to qualify the object with the schema name ....

    insert into apc.whatever_table  values ...
    

    or else we need to create a synonym for it

    create synonym whatever for apc.whatever_table;
    

提交回复
热议问题