9

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

1 Answer 1

14
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

Sign up to request clarification or add additional context in comments.

2 Comments

Is there a way to say DROP TRIGGER IF EXISTS?
Yes use: DROP TRIGGER IF EXISTS rr_admin_reports ON yourTable; :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.