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
Use the DROP TRIGGER statement to remove a database trigger from the database. The trigger must be in your own schema or you must have the DROP ANY TRIGGER system privilege. To drop a trigger on DATABASE in another user's schema, you must also have the ADMINISTER DATABASE TRIGGER system privilege.
You can remove triggers using the Remove Physical File Trigger (RMVPFTRG) command, the SQL DROP TRIGGER statement, or System i® Navigator. Use the RMVPFTRG command to remove the association of a file and the trigger program.
To drop a PostgreSQL trigger, we use the DROP TRIGGER statement with the following syntax: DROP TRIGGER [IF EXISTS] trigger-name ON table-name [ CASCADE | RESTRICT ];
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With