DROP_TRIGGER(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

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 the CASCADE vs RESTRICT thing matters โ€” CASCADE takes the whole friend group down with it, RESTRICT is 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