I have a PostgreSQL table with 15 columns. I have an on update trigger on it. I'd like to exclude column10 from it. Meaning when there is any update on column10 only then there should not be any action other than it. If full update or any other column update, trigger should fire as normal.

I don't seem to find any easy way to do this. Can someone suggest please?


Documentation shows that you can define specific columns in an on update trigger:

create trigger foo
after update of column1, column2, ... -- other columns, except column10
on your_table ...
  • 1
    Thanks for the update. The problem is we have to keep on changing trigger function code whenever table structure changes, meaning if we add col16 then trigger code should be changed to accommodate this. Wondering if there is any easy way to exclude one column instead of using rest of them. Is there something like IF NOT UPDATE(column) - we can use in postgresql?
    – rjolax
    Nov 29 '19 at 8:37

You can catch the update of column10 in the trigger function

IF OLD.column10 = NEW.column10 THEN
  ... do the trigger stuff ...
  ... do nothing, because column10 has been changed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.