Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drop trigger if exists in MySQL

Tags:

mysql

triggers

I need to execute a command similar to the following not inside a procedure but inside a simple sql file for mysql 5.xx

IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_NAME =  'tr_fnninio_censopersona_ins') THEN
    DROP TRIGGER tr_fnninio_censopersona_ins;
END IF;
like image 763
richardtk_1 Avatar asked Aug 22 '13 01:08

richardtk_1


People also ask

How do I delete an existing trigger in MySQL?

To destroy the trigger, use a DROP TRIGGER statement. You must specify the schema name if the trigger is not in the default schema: mysql> DROP TRIGGER test.

Which is an another method to drop a trigger in SQL?

Remarks. You can remove a DML trigger by dropping it or by dropping the trigger table.


1 Answers

Why not just

DROP TRIGGER IF EXISTS tr_fnninio_censopersona_ins;

MySQL drop trigger doc

like image 147
juergen d Avatar answered Nov 14 '22 13:11

juergen d