Oracle如果表存在则删除,以及其他语句

declare

      num  number; //声明一个参数 a 类型为 number类型 

begin

    select count(1) into num from user_tables where table_name = upper('temp1') ;

//查询 表temp1放入number

    if num > 0 then

        execute immediate 'drop table temp1' ;

//是用于在 存储过程里面. 动态的执行 SQL 语句。

    end if;//结束if语句

end;//结束这个程序

用的是存储过程删除表temp1;

如果是sqlite就用drop table if exists temp1;

转载于:https://www.jianshu.com/p/7bb5c38ea6c3

猜你喜欢

转载自blog.csdn.net/weixin_33859231/article/details/91109620