Check table exist or not before create it in Oracle

前端 未结 8 1156
清酒与你
清酒与你 2021-02-01 03:07

Trying to check is table exist before create in Oracle. Search for most of the post from Stackoverflow and others too. Find some query but it didn\'t work for me.



        
8条回答
  •  粉色の甜心
    2021-02-01 03:32

    declare n number(10);
    
    begin
       select count(*) into n from tab where tname='TEST';
    
       if (n = 0) then 
          execute immediate 
          'create table TEST ( ID NUMBER(3), NAME VARCHAR2 (30) NOT NULL)';
       end if;
    end;
    

提交回复
热议问题