DROP TABLE [IF EXISTS] table-name
Drop table if exists has been there for ages, in Oracle MySQL, Oracle NoSQL and others. Now we got this in Oracle Database 23c too.
First thing I do on my sandbox database is creating SCOTT tables. Now, for the first time, I can make my script 100% error free.
SQL> ed ?/rdbms/admin/utlsampl conn / as sysdba whenever sqlerror exit failure alter session set container=freepdb1; DROP USER IF EXISTS SCOTT CASCADE; DROP USER IF EXISTS ADAMS CASCADE; DROP USER IF EXISTS JONES CASCADE; DROP USER IF EXISTS CLARK CASCADE; DROP USER IF EXISTS BLAKE CASCADE; create user scott; GRANT CONNECT,RESOURCE,UNLIMITED TABLESPACE TO SCOTT ; DROP PUBLIC SYNONYM IF EXISTS PARTS; alter session set current_schema=scott; SQL> @?/rdbms/admin/utlsampl Disconnected from Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release Version 23.2.0.0.0 $ echo $? 0