欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

oracle刪除已存在的表的實例

 更新時間:2013年02月28日 10:55:01   作者:  
查詢系統(tǒng)表,判斷表是否存在,存在則直接刪除
Sql代碼
復(fù)制代碼 代碼如下:

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; 
/  

相關(guān)文章

最新評論