MySQL 5.0 can not drop and create trigger

5.4k views Asked by At

I'm using MySQL 5.0. I try to drop and recreate the trigger. When I drop the trigger it says:

mysql> drop trigger ads_delete;
ERROR 1360 (HY000): Trigger does not exist

Then I try to create the trigger with the same name. It says:

ERROR 1359 (HY000): Trigger already exists

Here is my trigger:

delimiter //

create TRIGGER ads_delete
BEFORE INSERT ON ads
FOR EACH ROW
BEGIN
update params set ads_count=ads_count-1, freq_weight=freq_weight-NEW.freq;
END//
2

There are 2 answers

3
Rahul Tripathi On

You need to drop the trigger like this:

USE db5;
DROP TRIGGER ads_delete;

Your trigger is in the db5 schema.

EDIT:

As OP commented that the problem is

BEFORE INSERT ON ads

ie, he is trying to create two triggers with the same instruction. (Probably a copy paste issue)

0
Jeff_Alieffson On

I found the error. The reason was my inadvertence. I copy/pasted my INSERT trigger, when changed the trigger name from ads_insert into ads_delete, I forgot to change BEFORE INSERT ON ads into BEFORE DELETE ON ads

Thanks to everyone.