oracle创建表之前判断表是否存在,如果存在则删除已有表
1个回答
2017-09-06
展开全部
oracle创建表之前判断表是否存在,如果存在则删除已有表
写个匿名块就行了,例子:
SQL> create table test(a number);
Table created
SQL>
SQL> declare
2 v_count number;
3 begin
4 select count(1) into v_count from user_tables t where t.TABLE_NAME='TEST';5 if v_count>0 then
6 execute immediate'drop table TEST';
7 end if;
8 execute immediate 'create table test(b number)';9 end;
10 /
PL/SQL procedure successfully completed
SQL> select * from test;
B
写个匿名块就行了,例子:
SQL> create table test(a number);
Table created
SQL>
SQL> declare
2 v_count number;
3 begin
4 select count(1) into v_count from user_tables t where t.TABLE_NAME='TEST';5 if v_count>0 then
6 execute immediate'drop table TEST';
7 end if;
8 execute immediate 'create table test(b number)';9 end;
10 /
PL/SQL procedure successfully completed
SQL> select * from test;
B
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询