DROP_TRIGGER(7pg18)
DROP TRIGGER ๐
okay bestie, so this is a page from the PostgreSQL 18.6 docs โ manual section 7, the SQL commands one. It's giving "how do I delete a trigger" energy, and honestly? Iconic. Let's get into it. ๐
โจ NAME โจ
DROP_TRIGGER โ remove a trigger, bye bye ๐๐
โจ SYNOPSIS โจ
DROP TRIGGER [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]
โจ DESCRIPTION โจ
So DROP TRIGGER does exactly what it says on the tin: it removes an existing trigger definition. Gone. Deleted. Not me ghosting that trigger. ๐
But โ and this is the important part, bestie โ to actually run this command, the current user has to be the owner of the table the trigger is defined on. No ownership, no dropping. That's the vibe check and you must pass it. ๐
โจ PARAMETERS โจ
IF EXISTSโ don't be dramatic about it. If the trigger doesn't exist, this stops it from throwing an error. Instead you just get a notice. Lowkey forgiving. ๐ซถnameโ the name of the trigger you're removing. The main character you're sending off. โจtable_nameโ the name of the table the trigger is defined for. It can be optionally schema-qualified, so you can be extra specific if you want. ๐CASCADEโ automatically drop the objects that depend on the trigger, and then, in turn, all the objects that depend on those objects. Yes, it's a whole chain reaction. See Section 5.15. ๐ฅRESTRICTโ refuse to drop the trigger if literally any objects depend on it. This is the default, so if you don't say anything, this is the energy you get. ๐
ngl theCASCADEvsRESTRICTthing matters โCASCADEtakes the whole friend group down with it,RESTRICTis the one that says "no, I'm not doing that, something needs me." ๐
โจ EXAMPLES โจ
Wanna destroy the trigger if_dist_exists on the table films? Say less:
DROP TRIGGER if_dist_exists ON films;
periodt. that trigger is no more. ๐ธ
โจ COMPATIBILITY โจ
Plot twist: the DROP TRIGGER statement in PostgreSQL is incompatible with the SQL standard. ๐ญ In the SQL standard, trigger names are not local to tables, so the command there is simply DROP TRIGGER name. No ON table_name situation. Different rules, different world. ๐ฆ
โจ SEE ALSO โจ
CREATE TRIGGER(CREATE_TRIGGER(7)) โ you know, the one that made the trigger in the first place ๐ง
and that's the whole page, bestie!! ๐โจ go forth and drop triggers responsibly, and remember: you gotta own the table. ๐๐
PostgreSQL 18.6 ยท 2026 ยท DROP TRIGGER(7) โ mwah, talk later! ๐
๐ธ
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms