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