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
不用判断,直接先执行删除你要创建的表名,然后再执行创建语句;
很完美,为什么要判断呢?