就个人而言,我看不出有什么理由要以这种方式创建表,但如果表不存在,这是另一种创建表的方法:
SQL> declare
2 table_exists exception;
3 pragma exception_init(table_exists, -955);
4 begin
5 execute immediate 'create table TestTable(TestFlag number(1) not null)';
6 dbms_output.put_line('table created');
7 exception
8 when table_exists
9 then dbms_output.put_line('table exists');
10 end;
11 /
table created
SQL> declare
2 table_exists exception;
3 pragma exception_init(table_exists, -955);
4 begin
5 execute immediate 'create table TestTable(TestFlag number(1) not null)';
6 dbms_output.put_line('table created');
7 exception
8 when table_exists
9 then dbms_output.put_line('table exists');
10 end;
11 /
table exists
PL/SQL procedure successfully completed