ALTER_TRIGGER(7pg17)

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

πŸ’– NAME πŸ’–

okay so bestie, welcome to the ALTER_TRIGGER page β€” the one that’s here to change the definition of a trigger. That’s literally the whole assignment. ✨

✨ SYNOPSIS ✨

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

πŸ’… DESCRIPTION πŸ’…

ALTER TRIGGER changes properties of an existing trigger. Not making a new one, just giving the existing one a little edit. 🫢

The RENAME clause changes the name of the given trigger without otherwise changing the trigger definition. If the table that the trigger is on is a partitioned table, then corresponding clone triggers in the partitions are renamed too. Slay, clones included. πŸ’…

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. So yeah, that attachment is real β€” extension goes bye, trigger goes bye too. 😭

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

πŸŽ€ PARAMETERS πŸŽ€

  • name β€” the name of an existing trigger to alter. The trigger in question, bestie.
  • table_name β€” the name of the table on which this trigger acts.
  • new_name β€” the new name for the trigger. The glow-up name. ✨
  • 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.

πŸ¦‹ 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 on/off switch, it’s giving ALTER TABLE energy, not ALTER TRIGGER. πŸ¦‹

πŸ”₯ 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. So it’s PostgreSQL’s own special little move. πŸ’–

πŸ‘‘ SEE ALSO πŸ‘‘

  • ALTER TABLE β€” that’s the ALTER_TABLE(7) page, bestie. Go read it if you need the table-level stuff. πŸ‘‘

πŸ’– sign-off: this page is sourced from PostgreSQL 17.11, dated 2026. mwah, periodt. 🫢
πŸ“¦ where this page comes from