ORACLE 判斷序列是否存在,如果存在就刪除
阿新 • • 發佈:2019-02-08
declare
V_NUM number;
BEGIN
----多次刪除時,每次都將v_num設定成為0
V_NUM := 0;
----判斷序列 seq_name_1 是否存在(區分大小寫)
select count(0) into V_NUM from user_sequences where sequence_name = 'SEQ_BUSINESS_PROCESS_INDEX_ID';
----如果存在立即刪除
if V_NUM > 0 then
execute immediate 'DROP SEQUENCE SEQ_BUSINESS_PROCESS_INDEX_ID';
end if;
----多次刪除時,每次都將v_num設定成為0
V_NUM := 0;
----判斷序列 seq_name_1 是否存在(區分大小寫)
select count(0) into V_NUM from user_sequences where sequence_name = 'SEQ_INTERFACE_SERVICE_ID';
----如果存在立即刪除
if V_NUM > 0 then
execute immediate 'DROP SEQUENCE SEQ_INTERFACE_SERVICE_ID';
end if;
END;