Oracle: If Table Exists

后端 未结 15 1513
无人共我
无人共我 2020-11-22 13:32

I\'m writing some migration scripts for an Oracle database, and was hoping Oracle had something similar to MySQL\'s IF EXISTS construct.

Specifically, w

15条回答
  •  眼角桃花
    2020-11-22 14:05

    With SQL*PLUS you can also use the WHENEVER SQLERROR command:

    WHENEVER SQLERROR CONTINUE NONE
    DROP TABLE TABLE_NAME;
    
    WHENEVER SQLERROR EXIT SQL.SQLCODE
    DROP TABLE TABLE_NAME;
    

    With CONTINUE NONE an error is reported, but the script will continue. With EXIT SQL.SQLCODE the script will be terminated in the case of an error.

    see also: WHENEVER SQLERROR Docs

提交回复
热议问题