begin
create table TABLE_A as
select * from TABLE;
create table TABLE_B as
select * from TABLE_A;
end;我想在一个过程里面写好多这样的CREATE语句,但希望建完第一个在建第二个,请问应该怎么写主要是晚间想备份好多表。。

解决方案 »

  1.   

    declare
       v_cnt number := 0;
    begin    create table TABLE_A as select * from TABLE;    select count(1) into v_cnt from user_objects where object_name = 'TABLE_A';
       if v_cnt = 1 then
          create table TABLE_B as select * from TABLE_A; 
          v_cnt := 0;
       end if;end;
      

  2.   

    declare
       v_cnt number := 0;
    begin 
       create table cxf_test as select * cxf_area; 
       select count(1) into v_cnt from user_objects where object_name = 'cxf_test';
       if v_cnt = 1 then
          create table cxf_test2 as select * from cxf_test; 
          v_cnt := 0;
       end if;
    end;提示如下错误啊
    ORA-06550: 第 4 行, 第 4 列: 
    PLS-00103: 出现符号 "CREATE"在需要下列之一时:
     ( begin case declare
       exit for goto if loop mod null pragma raise return select
       update while with <an identifier>
       <a double-quoted delimited-identifier> <a bind variable> <<
       continue close current delete fetch lock insert open rollback
       savepoint set sql execute commit forall merge pipe purge
      

  3.   


    plsql块里不能有ddl语句,如果实在是需要执行ddl语句,只能通过execute immediate 'create table TABLE_A as select * from TABLE';这样的方式