oracle删除已存在的表的实例

发布时间:2022-04-20 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了oracle删除已存在的表的实例脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
SQL代码
复制代码 代码如下:

select count(*) From user_objects where object_name=upPEr(p_table_name); 
select count(*) from user_tables where table_name=upper(p_table_name); 

create or replace PRocedure p_drop_table_if_exist_v1( 
p_table_name in vArchar2 
) is 
v_count number(10); 
begin 
select count(*) 
into v_count 
from user_objects 
where object_name=upper(p_table_name); 
if v_count > 0 then 
execute immediate 'drop table ' || p_table_name || ' purge'; 
end if; 
exception 
when no_data_found then 
    begin 
        null; 
    end; 
end; 
/  

create or replace procedure p_drop_table_if_exist_v2( 
p_table_name in VARchar2 
) is 
v_table_name varchar2(20); 
begin 
select table_name  
into v_table_name  
from user_tables  
where table_name=upper(p_table_name); 
if length(v_table_name)>0 then   
execute immediate 'drop table ' || p_table_name || ' casCADe constraints';  
end if; 

exception 
when no_data_found then 
    begin 
        null; 
    end; 
end; 
/  

脚本宝典总结

以上是脚本宝典为你收集整理的oracle删除已存在的表的实例全部内容,希望文章能够帮你解决oracle删除已存在的表的实例所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:oracleoracle