a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 149|回复: 0

[考试辅导] Oracle技术:oracle创建表时判断表存在语句的方法

[复制链接]
发表于 2012-8-4 14:06:19 | 显示全部楼层 |阅读模式
declare  cnt number;   begin
% j; `4 a7 q$ o7 K  ---发芽要建树的表是否存在
) k0 e8 r# a9 K) u! _  select count(*)into cnt from user_tables where table_name='ENTRY_MODIFYSTATUS';5 B6 A9 f5 O/ F8 h: T0 a
  ---如不美观存在则删除该表1 `+ q1 M  H9 T7 B: [
  if cnt>0 then% {% Y. d) ^$ R5 ~* T" f+ T' ~
  dbms_output.put_line('表存在不建树');6 @" \1 w" i7 q* K2 O- ^" s
  else- V" M& ?3 {) u+ S
  dbms_output.put_line('表不存在');$ P( m0 ?- x! @6 I9 p6 j
  execute immediate 'create table ENTRY_MODIFYSTATUS  (
' p  x( W' M, a2 b$ B4 p. L, s  ENTRY_ID             VARCHAR2(18)                    not null,5 ?8 i$ s( W3 N7 c
  APPLY_TIME           DATE                            not null,# r8 ?! g& ~+ d& k- `- K2 Z6 u
  STATUS               NUMBER(2),3 V3 t+ Y3 p6 |- i
  constraint PK_ENTRY_MODIFYSTATUS primary key (ENTRY_ID, APPLY_TIME)
: ~% a, B' z. s% |: Z6 S$ T8 w  )';4 [7 a+ L. B. X. F; |1 W# z
  end if;
2 A; w; q  }% V& R  cnt:=0;8 b; F* F: h) g3 T
  end;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-5 20:27 , Processed in 0.245835 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表