ORACLE—003:Create之创建表前判断表是否存在

时间:2014-06-08 15:42:00   收藏:0   阅读:329

建表前如何判断表是否存在呢,因为table是不支持replace的。下面的sql能帮到你。

create前先判断表是否存在。例如,如果存在则drop掉那个表。当然你也可以定义自己的操作。

 declare
   v_cnt Number; 
begin 

    select count(*) into v_cnt  from user_tables where upper(table_name) like ‘%TMP_CLOB_SQL%‘; 

    if v_cnt>0 then 
       execute immediate ‘DROP TABLE TMP_CLOB_SQL‘;
    end If; 
End;
/
create table youttable
(
)
注意:别忘了加斜杠。

ORACLE—003:Create之创建表前判断表是否存在,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!