Oracle: Drop table if exists replacement
Mysql has a nice “if exists” addition to the drop table statement. If the table to be dropped does not exists, it doesn’t raise an exception but only creates a warning.
In Oracle RDMBS you can emulate this behavior like so:
BEGIN EXECUTE immediate 'drop table INSERT_TABLE_NAME_HERE'; EXCEPTION WHEN others THEN IF SQLCODE != -942 THEN RAISE; END IF; END;
/ |
Ugly, but it works very well.
Share This
Mysql has a nice “if exists” addition to the drop table statement. If the table to be dropped does not exists, it doesn’t raise an exception but only creates a...
— Trackback URI
This entry (permalink) was posted on Tuesday, February 16, 2010, at 12:18 pm by Michael, tagged with Code Snippets and categorized in English posts, Oracle.
The following post could be of some interest: Javas String.replaceAll, Optimizing the Oracle Query Optimizer, Oracle, JBDC, CallableStatements and named parameters, How to retrieve tables of custom object types with JDBC, Oracle XE environment variables on Linux, Simple tokenizing with Oracle PL/SQL, Upgrading to WordPress 2.3 “Dexter”, Frustration, Unicode substrings in Ruby 1.8.x, mysqldump / mysql tips
Post a Comment