会计考友 发表于 2012-8-4 14:06:19

Oracle技术:oracle创建表时判断表存在语句的方法

declarecnt 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;
页: [1]
查看完整版本: Oracle技术:oracle创建表时判断表存在语句的方法