Oracle 的drop table if exists功能

古城微笑少年丶 2023-07-21 05:55 58阅读 0赞

Mysql 创建表之前判断表是否存在,如果存在则删除已有表

  1. DROP TABLE IF EXISTS SH_PLACARD_INFO;

Oracle 创建表之前判断表是否存在,如果存在则删除已有表

  1. declare
  2. num number;
  3. begin
  4. select count(1) into num from user_tables where table_name = upper('SH_PLACARD_INFO') ;
  5. if num > 0 then
  6. execute immediate 'drop table SH_PLACARD_INFO' ;
  7. end if;
  8. end;

发表评论

表情:
评论列表 (有 0 条评论,58人围观)

还没有评论,来说两句吧...

相关阅读

    相关 mysql drop if命令

    在 MySQL 数据库中,虽然没有提供原生的 DROP IF 命令,但通过使用条件语句和IF EXISTS关键字,可以实现类似的效果,避免在删除对象时出现错误。合理利用 ...