ALTER_TRIGGER(7pg16)
π 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, ifNOis specified). A trigger that's marked as dependent on an extension is automatically dropped when the extension is dropped. so like,NOis 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
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms