Oracle

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

日期:2015-06-28 00:00:00 来源: IT猫扑网

  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;

相关文章

相关下载

网友评论

我要评论...
    没有更早的评论了
    取消