MySQL Forums
Forum List  »  Triggers

Re: Check for existence of a trigger
Posted by: Arjen Lentz
Date: March 10, 2005 10:34PM

CMS wrote:
> (Using 5.0.2-alpha-max)
>
> For tables, you can conditionally drop them. That is, drop them if they exist, or do nothing if they
> don't. For example:
> DROP TABLE IF EXISTS `MyTable`;
>
> The DROP TRIGGER statement doesn't seem to support the "IF EXISTS" clause. And since attempting
> to drop a trigger that does not exist causes a 1360 error (Trigger does not exist) and aborts my
> script, I can't simply have the script try to drop a trigger without know if it's there or not.

Please make the feature suggestion in bugs.mysql.com (indeed, it's not only for bugs!) so the developers will spot it. It's a good question. Thanks.

> In Oracle, I think I could do a "CREATE OR REPLACE".

Perhaps also add this, it may not be difficult to also support this syntax.


> In SQL Server, I could just peek in the sysobjects table to see if an object exists or not. I don't see
> anything in MySQL where I can look at the object inventory.

The SQL standard way for this, supported in MySQL 5.0, is INFORMATION_SCHEMA.
There will be a INFORMATION_SCHEMA.TRIGGERS in the near future.
See http://dev.mysql.com/doc/mysql/en/information-schema-tables.html

Regards, Arjen.
--
Arjen Lentz, Exec.Director @ Open Query (http://openquery.com)
Remote expertise & maintenance for MySQL/MariaDB server environments.

Follow us at http://openquery.com/blog/ & http://twitter.com/openquery

Options: ReplyQuote


Subject
Views
Written By
Posted
8118
CMS
March 10, 2005 04:23PM
Re: Check for existence of a trigger
3687
March 10, 2005 10:34PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.