AnApprentice
AnApprentice

Reputation: 110960

How to drop multiple triggers in a PostgreSQL 9.1 DB

I'm trying to remove multiple triggers but getting a SQL error:

PG::Error: ERROR:  syntax error at or near ";"
LINE 1:     DROP TRIGGER rr_admin_reports;

Here is the sql I'm executing in rails:

sql = <<-SQL
  DROP TRIGGER rr_admin_reports;
  DROP TRIGGER rr_apps;
  DROP TRIGGER rr_attachments;
SQL

Is there a way to easily delete a long list of triggers? Thanks

Upvotes: 9

Views: 10378

Answers (1)

Floris Velleman
Floris Velleman

Reputation: 4888

DROP TRIGGER rr_admin_reports ON yourTable;

Quote from PostgreSQL documentation:

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 is simply DROP TRIGGER name.

http://www.postgresql.org/docs/7.4/static/sql-droptrigger.html

Upvotes: 14

Related Questions