In my application I have a dynamic system, so I have to check if a table is already existing and exceptionally create it on demand. This is no problem by doing a create table if not exists.
But since mysql does not support “if not exists” in the create trigger statement, I want to ask if there is another workaround than dropping the trigger? It makes no sense to me to drop a trigger to recreate it every time, I just want to create a missing trigger. This event should happen once while a drop and recreate will happen often. The trigger is neccessary for audit/logging purpose.
Maybe we can do it in oracle way, where you could wrap the create ddl in a begin/end and then do null in the exception hanlder?
Use a CREATE TRIGGER statement. If trigger exists you will get an exception, just catch it.
If you do not want to catch errors, then you may check existence –