多谢楼上,再补充个小问题,如果我想实现如下功能: if (sequence_a存在) drop sequence_a, 怎么写?我用sqlserver里的if exists() then 报错
declare v_count int; begin select count(*) into v_ount from user_objects where object_type = 'SEQUENCE' and object_name = &name; if v_int >0 then execute immediate 'drop sequence &name'; end if ; end; /
'drop sequence &name' ^_^
select * from user_sequences;
请慎用'&'符号,:) declare v_count int; begin select count(*) into v_ount from user_objects where object_type = 'SEQUENCE' and object_name = 'MY_SEQ_NAME'; if v_int >0 then execute immediate 'drop sequence MY_SEQ_NAME'; end if ; end; /
怎么写?我用sqlserver里的if exists() then 报错
v_count int;
begin
select count(*) into v_ount from user_objects
where object_type = 'SEQUENCE' and object_name = &name;
if v_int >0 then
execute immediate 'drop sequence &name';
end if ;
end;
/
declare
v_count int;
begin
select count(*) into v_ount from user_objects
where object_type = 'SEQUENCE' and object_name = 'MY_SEQ_NAME';
if v_int >0 then
execute immediate 'drop sequence MY_SEQ_NAME';
end if ;
end;
/