oracle删除已存在的表的实例

前端之家收集整理的这篇文章主要介绍了oracle删除已存在的表的实例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

sql代码
<div class="codetitle"><a style="CURSOR: pointer" data="115" class="copybut" id="copybut115" onclick="doCopy('code115')"> 代码如下:

<div class="codebody" id="code115">
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;
/

原文链接:https://www.f2er.com/oracle/65597.html

猜你在找的Oracle相关文章