0

Here is the query to disable all triggers in a particular table:

alter table plan_items DISABLE TRIGGER ALL

But I'm getting access issues while executing the query. How do we execute the same query passing for a particular database user? I want to delete triggers that are only part of the mentioned database user.

2 Answers 2

1

You can configure a user so that ordinary triggers won't fire for it:

ALTER ROLE myuser SET session_replication_role = replica;
Sign up to request clarification or add additional context in comments.

10 Comments

Thank you for the response. How can I rollback these changes?
And how can we restrict this for a particular table, rather than disabling triggers for all tables?
You can undo it with ALTER TABLE ... RESET session_replication_role;. I don't think you can disable triggers only for one user and table.
When we do ALTER ROLE myuser SET session_replication_role = replica;, isn't the case where we disable triggers for all tables? In that case, how do we rollback changes in all tables? we need to manually hit alter table query for all tables?
No, it is applied to a single user. Undo it, and triggers will fire again for that user.
|
0

Seems like the below query does the exact job:

ALTER TABLE table DISABLE TRIGGER USER;

This will disable normal triggers added by the database user.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.