简体   繁体   中英

Oracle 12c not sufficient privileges on trigger creation

I want to execute code on user IDK :

CREATE OR REPLACE TRIGGER sal_trig
  AFTER UPDATE OF status ON TAB1
  FOR EACH ROW
  WHEN (new.status = 'ZAK')
CALL log_sal(1, 5, 8);

I have following grants:

GRANT CREATE PROCEDURE TO IDK;
GRANT CREATE SEQUENCE TO IDK;
GRANT CREATE TABLE TO IDK;
GRANT CREATE TRIGGER TO IDK;
GRANT CREATE TYPE TO IDK;
GRANT UNLIMITED TABLESPACE TO IDK;
GRANT SELECT ON TAB1 TO IDK;

What grants i need more? I won't get update/delete/insert on TAB1 . I am getting error: not sufficient privileges .

I created procedure from user IDK :

CREATE OR REPLACE PROCEDURE log_sal (
  emp_id NUMBER,
  old_sal NUMBER,
  new_sal NUMBER
)
AS LANGUAGE JAVA
NAME 'CaseWatch.logSal(int, float, float)';

According to your comments the TAB1 table created by different User, so the table is in a different schema, this is the main key. When you want to grant privileges to create a trigger on a table in different schema then you need to use:

GRANT CREATE ANY TRIGGER TO IDK;

CREATE TRIGGER => in fact giving permission to create a database trigger in the grantee's schema, in your case if TAB1 created by IDK then this privilege is enough.

Regarding the CREATE ANY TRIGGER here you can find some more interesting info:

  1. https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_9013.htm
  2. Grant create any trigger vs grant create trigger

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM