Bug #32927 Create/drop trigger: if (not) exists and recreate if exists
Submitted: 3 Dec 2007 13:25 Modified: 14 Dec 2007 9:11
Reporter: Olaf van der Spek (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S4 (Feature request)
Version:* OS:Any
Assigned to: CPU Architecture:Any
Tags: qc

[3 Dec 2007 13:25] Olaf van der Spek
Description:
http://dev.mysql.com/doc/refman/5.1/en/create-trigger.html

Hi,

Create trigger doesn't support if not exists like create table. Drop trigger doesn't support if exists.
Could you add those two?
Create trigger recreate if exists might be a nice shortcut too.

How to repeat:
-
[3 Dec 2007 14:05] Valeriy Kravchuk
Thank you for a reasonable feature request.
[14 Dec 2007 9:11] Olaf van der Spek
I just noticed "DROP TRIGGER [IF EXISTS]" is supported. I guess I only looked at create trigger and assumed drop trigger wouldn't support if exists either.
As a drop trigger if exists ?; create trigger series works fine, I'm closing this request.
[4 Mar 2012 19:09] MELERIX ...
DROP TRIGGER IF EXIST is still not working...

for example:

DROP TRIGGER IF EXIST `set_current_date`;
CREATE TRIGGER `set_current_date` BEFORE INSERT ON `characters` FOR EACH ROW SET NEW.createDate = curdate();

it will throw:

[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'EXIST `set_current_date`' at line 1
[Err] DROP TRIGGER IF EXIST `set_current_date`;