--检查表是否存在
function is_tab_exist(v_tab_name varchar2,v_dblink_name varchar2 default null) return boolean
as
n_count number default 0;
b_result boolean default false;
begin
--在用户表中查询
execute immediate 'select count(1) from user_tables'||case when v_dblink_name is not null then '@'||v_dblink_name end||' where table_name=upper('''||v_tab_name||''')' into n_count;
if n_count > 0 then
b_result := true;
end if;
return b_result;
exception
when others then return false;
end is_tab_exist;