oracle 创建表时判断表是否存在语句

declare  cnt number;

begin
   ---查询要创建的表是否存在
   select count(*)into cnt from user_tables where table_name='ENTRY_MODIFYSTATUS';
   ---如果存在则删除该表
   if cnt>0 then
      dbms_output.put_line('表存在不创建');
   else
       dbms_output.put_line('表不存在');
    execute immediate 'create table ENTRY_MODIFYSTATUS  (
       ENTRY_ID             VARCHAR2(18)                    not null,
       APPLY_TIME           DATE                            not null,
       STATUS               NUMBER(2),
       constraint PK_ENTRY_MODIFYSTATUS primary key (ENTRY_ID, APPLY_TIME)
    )';
  end if;
 
  cnt:=0;
end;

/

原文地址:https://www.cnblogs.com/amylis_chen/p/1780633.html