oracle删除已存在的表的实例

时间:2024-01-16 19:24:58 

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,删除表
0
投稿

猜你喜欢

  • Go语言导出内容到Excel的方法

    2024-02-11 17:18:56
  • python操作docx写入内容,并控制文本的字体颜色

    2023-11-25 03:14:33
  • Centos7.2 编译安装PHP7.0.2的步骤

    2023-10-08 12:51:29
  • 解决pycharm最左侧Tool Buttons显示不全的问题

    2022-11-22 13:23:22
  • python数据处理 根据颜色对图片进行分类的方法

    2022-02-27 08:41:37
  • Python3.5实现的三级菜单功能示例

    2023-08-01 13:37:26
  • MySQL视图简介及基本操作教程

    2024-01-24 14:51:51
  • Go单元测试工具gomonkey的使用

    2024-05-22 10:19:21
  • golang 输出重定向:fmt Log,子进程Log,第三方库logrus的详解

    2024-04-27 15:40:14
  • Python爬虫框架NewSpaper使用详解

    2022-06-03 06:20:26
  • 通过事务日志解决SQL Server常见四大故障(一)

    2009-03-25 13:46:00
  • Linux oracle数据库自动备份自动压缩脚本代码

    2024-01-19 01:44:40
  • Python实现常见坐标系的相互转换

    2021-11-15 18:32:48
  • php实现贪吃蛇小游戏

    2024-05-02 17:16:36
  • Python 如何读取字典的所有键-值对

    2021-05-21 10:06:53
  • Python3实现获取图片文字里中文的方法分析

    2023-09-19 09:31:34
  • python 利用opencv实现图像网络传输

    2023-05-27 12:52:16
  • Python+Tkinter制作在线个性签名工具

    2023-12-25 15:21:23
  • Quickwork For Asp -实战之后台管理

    2009-12-31 19:13:00
  • SQL Server创建索引教程

    2010-07-02 21:09:00
  • asp之家 网络编程 m.aspxhome.com