Answer the question
In order to leave comments, you need to log in
How to implement a trigger that prevents the user from editing a table?
Hello! Help, please solve the problem. You need to write a trigger that uses an autonomous transaction, prohibits the user from editing table data and saves information about it in a special log. Thank you.
Answer the question
In order to leave comments, you need to log in
Such things need to be regulated by the rights to the table. For example:
GRANT INSERT, UPDATE, DELETE ON schema.tablename TO username; --Дать права
REVOKE INSERT, UPDATE, DELETE ON schema.tablename FROM username; --Отозвать права
create or replace trigger MY_TRIGGER_NAME
before insert or update or delete
on MY_TABLE_NAME
begin
if user in ( 'BAD_USER', 'ANGRY_USER' ) then raise_application_error( -20001,'You do not have access to modify this table.' );
end if;
end;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question