ALTER_TRIGGER(7pg16)

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

πŸ’… ALTER_TRIGGER β€” change the definition of a trigger

okay so real talk, bestie: this is the ALTER TRIGGER page from the PostgreSQL 16.15 Documentation, and it's honestly so much chiller than it sounds. We're not creating anything, we're not dropping anything β€” we're just giving an existing trigger a little glow-up ✨


🌸 SYNOPSIS 🌸

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

like, that's it. two whole moves. icon behavior honestly πŸŽ€


πŸ’– DESCRIPTION πŸ’–

ALTER TRIGGER changes properties of an existing trigger. that's the whole assignment, and it ate. πŸ’…

The RENAME clause changes the name of the given trigger without otherwise changing the trigger definition. no cap, nothing else about it changes β€” just the name. and here's the cute part: if the table that the trigger is on is a partitioned table, then corresponding clone triggers in the partitions get renamed too 🫢 the whole squad gets a rebrand, it's giving coordinated group chat name change.

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 like… you two are linked. ride or die. if the extension goes, the trigger goes with it, no questions asked 😭

⚠️ okay important vibe check: you must own the table on which the trigger acts to be allowed to change its properties. no ownership, no glow-up. periodt.

✨ PARAMETERS ✨

  • name β€” the name of an existing trigger to alter. the one you're choosing to bless today.
  • table_name β€” the name of the table on which this trigger acts. yes, the actual table. yes, you need to name it.
  • new_name β€” the new name for the trigger. the rebrand. the fresh identity. πŸ¦‹
  • 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 like, NO is the ✨uncoupling era✨ if you catch my drift.

🧚 NOTES 🧚

okay so this one's important and lowkey a little funny: the ability to temporarily enable or disable a trigger is provided by ALTER TABLE, not by ALTER TRIGGER. why? because ALTER TRIGGER has no convenient way to express the option of enabling or disabling all of a table's triggers at once. 😭 it's not a skill issue, it's a syntax issue. wrong manpage, bestie β€” go hit up ALTER TABLE for that one. iykyk.


πŸ”₯ EXAMPLES πŸ”₯

To rename an existing trigger:

ALTER TRIGGER emp_stamp ON emp RENAME TO emp_track_chgs;

look at that glow-up. emp_stamp β†’ emp_track_chgs. main character energy honestly πŸ‘‘

To mark a trigger as being dependent on an extension:

ALTER TRIGGER emp_stamp ON emp DEPENDS ON EXTENSION emplib;

now they're bonded fr fr πŸ’œ


🌈 COMPATIBILITY 🌈

ALTER TRIGGER is a PostgreSQL extension of the SQL standard. so like, it's our thing, not the standard's thing. we invented it, we slay with it πŸ’…


πŸŽ€ SEE ALSO πŸŽ€

  • ALTER TABLE (ALTER_TABLE(7)) β€” the one that actually handles enabling/disabling triggers, remember?

and that's the page!! πŸ“ written for PostgreSQL 16.15, dated 2026 β€” mwah, drink water, back up your tables, and go rename something πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from