a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 152|回复: 0

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

[复制链接]
发表于 2012-8-4 14:06:19 | 显示全部楼层 |阅读模式
declare  cnt number;   begin
4 b, m! ]) p# q8 x- ^2 v9 [$ f  ---发芽要建树的表是否存在* W3 t/ L7 l7 M  g, b( z
  select count(*)into cnt from user_tables where table_name='ENTRY_MODIFYSTATUS';
  d$ U) j6 h; g' I/ Q. Z6 m  ---如不美观存在则删除该表
$ Q& b& `8 [- `! q9 D) I  if cnt>0 then
5 {* d+ v+ e$ u# l  dbms_output.put_line('表存在不建树');
0 H: z2 m5 ]  J/ p  else3 X( M3 _+ p3 U4 h7 ^- w
  dbms_output.put_line('表不存在');( C, T- M" J0 ~5 C9 _8 Z, y& A( F1 G
  execute immediate 'create table ENTRY_MODIFYSTATUS  (
; S) X/ v6 s2 E7 V9 u  ENTRY_ID             VARCHAR2(18)                    not null,. g( {' e/ q8 h1 Z; Y5 u7 R$ _
  APPLY_TIME           DATE                            not null,
, ?7 l3 `- a( P, p" e2 l( O  STATUS               NUMBER(2),
) ~7 x& k4 f: q2 o* y1 B  constraint PK_ENTRY_MODIFYSTATUS primary key (ENTRY_ID, APPLY_TIME)
; c1 j( l6 A- g  )';
5 _0 @& g5 ^9 m% k: L  end if;
: \' S+ W- r. B+ s0 y  cnt:=0;
0 Y* N4 |8 Q; |" v* i  `  end;
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-19 04:58 , Processed in 0.179119 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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