您的位置:首页 > 其它

新增数据表或字段

2017-07-17 17:48 120 查看

判断表是否存在,如果存在则删除

declare
num number;
begin
select count(1) into num from user_tables where TABLE_NAME = 'BOOKING_INFO';
if   num=1   then
execute immediate 'drop table BOOKING_INFO';
end   if;
END;
/


判断表是字段是否存在,如果存在则删除

declare
num number;
begin
select count(1) into num From All_Tab_Columns Where Table_Name='BOOKING_INFO' And Column_Name='IMPORT_STATUS';
if   num=1   then
execute immediate 'alter table BOOKING_INFO drop (IMPORT_STATUS)';
end   if;
End;
/


判断序列是否存在,如果存在则删除

declare
num number;
begin
SELECT count(1) into num FROM dba_sequences where SEQUENCE_NAME='EDI_LFC_SEND_SEQ';
if   num=1   then
execute immediate 'drop sequence EDI_LFC_SEND_SEQ';
end   if;
END;
/
--创建序列
CREATE SEQUENCE EDI_LFC_SEND_SEQ INCREMENT BY 1 MAXVALUE 99999 MINVALUE 1 CYCLE CACHE 20;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: