ALTER_TRIGGER(7pg14)

πŸ“¦ version 14.24, in opensuse-leap 16.0

πŸ’… ALTER TRIGGER(7) πŸ’…

okay bestie, welcome to the PostgreSQL 14.24 Documentation page for ALTER_TRIGGER β€” yes, that's the manual name, and yes, we're about to make trigger edits make sense. 🫢

🌸 NAME 🌸

ALTER_TRIGGER β€” change the definition of a trigger.

✨ SYNOPSIS ✨

ALTER TRIGGER name ON table_name RENAME TO new_name
ALTER TRIGGER name ON table_name [ NO ] DEPENDS ON EXTENSION extension_name

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so ALTER TRIGGER changes properties of an existing trigger. Not creating one β€” existing. Main character behavior only. πŸ’…

The RENAME clause changes the name of the given trigger without otherwise changing the trigger definition. So it's giving new name, same trigger energy. πŸŽ€

The DEPENDS ON EXTENSION clause marks the trigger as dependent on an extension, such that if the extension is dropped, the trigger will automatically be dropped as well. No cap, the dependency is real. ⚠️

You must own the table on which the trigger acts to be allowed to change its properties. Own the table, get the power. πŸ‘‘

πŸŽ€ PARAMETERS πŸŽ€

  • name β€” the name of an existing trigger to alter. It's gotta already exist, bestie.
  • table_name β€” the name of the table on which this trigger acts.
  • new_name β€” the new name for the trigger. Fresh name, same trigger.
  • extension_name β€” the name of the extension that the trigger is to depend on (or no longer dependent on, if NO is specified). A trigger that's marked as dependent on an extension is automatically dropped when the extension is dropped. So yes, if the extension goes, the trigger goes too. 🫠

πŸ’‘ NOTES πŸ’‘

The ability to temporarily enable or disable a trigger is provided by ALTER TABLE, not by ALTER TRIGGER, because ALTER TRIGGER has no convenient way to express the option of enabling or disabling all of a table's triggers at once. So if you're looking for the enable/disable switch, bestie, that's an ALTER TABLE thing. 🚨

πŸ”₯ EXAMPLES πŸ”₯

To rename an existing trigger:

ALTER TRIGGER emp_stamp ON emp RENAME TO emp_track_chgs;

To mark a trigger as being dependent on an extension:

ALTER TRIGGER emp_stamp ON emp DEPENDS ON EXTENSION emplib;

🌈 COMPATIBILITY 🌈

ALTER TRIGGER is a PostgreSQL extension of the SQL standard. It's built different, iykyk. πŸ’…

πŸ‘€ SEE ALSO πŸ‘€


mwah πŸ’‹ this page was served fresh with PostgreSQL 14.24, dated 2026, and it's literally titled ALTER TRIGGER(7). go own that table and slay those triggers, bestie. πŸŽ€βœ¨

πŸ“¦ where this page comes from