APP NEWS

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

declare cntnumber;begin---查询要创建的表是否存在selectcount(*)intocntfromuser_tableswheretable_name='ENTRY_MODIFYSTATUS';---如果存在则删除该表ifcnt>0thendbms_output.put_line('表存在不创建');else

2015-06-28 00:000 次阅读
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;

关键词标签:oracle

YOU MAY ALSO LIKE

更多应用推荐

浏览应用库