网站首页
JSP空间
动态资讯
开源项目
技术文档
资源下载
J2EE资源
客户论坛
在线支付
 
  技术文档>>数据库技术>>Oracle技术>>Oracle开发>查看文档  
  怎样才能删除所有表中的"procedure"     
  文章作者:未知  文章来源:赛迪网技术社区  
  查看:89次  录入:管理员--2008-02-29  
 

问题:如何删除所有表的procedure?

解决此问题的示例:

create procedure proc_drop_all_tables()
begin
declare v_tablename varchar(50);
declare v_constname varchar(50);
declare flag int default 0;
--定义一个游标,寻找所有的外键
declare cur_constraint cursor for 
select table_name,constraint_name
from information_schema.table_constraints
where constraint_type='foreign key'
and table_schema=(select database());
--定义一个游标,寻找所有表
declare cur_table cursor for select table_name 
from information_schema.tables
where table_type='base table' and table_schema=( select database());
--定义一个游标,寻找所有视图
declare cur_view cursor for select table_name 
from information_schema.tables
where table_type='view' and 
table_schema=( select database());
declare continue handler for not found
set flag=1;
--循环去删除所有外键
open cur_constraint;
repeat
fetch cur_constraint into v_tablename,v_constname;
if flag= 0 then
set @v_sql = concat('alter table ',v_tablename,' 
drop foreign key ',v_constname);
prepare stmt from @v_sql;
execute stmt;
end if;
until flag=1
end repeat;
close cur_constraint;
set flag=0;
--循环去删除所有视图
open cur_view;
repeat
fetch cur_view into v_tablename;
if flag=0 then
set @v_sql = concat('drop view ',v_tablename);
prepare stmt from @v_sql;
execute stmt;
end if;
until flag=1
end repeat;
set flag=0;
close cur_view;
--循环去删除所有表
open cur_table;
repeat
fetch cur_table into v_tablename;
if flag = 0 then
set @v_sql = concat('drop table ',v_tablename);
prepare stmt from @v_sql ;
execute stmt ;
end if;
until flag=1
end repeat;
deallocate prepare stmt;
close cur_table;
end;

 
 
上一篇: 如何才能限制用户对自己对象的ddl权限    下一篇: 如何对系统默认的约束名和索引名重命名
  相关文档
轻松掌握什么是数据的物理(存储)结构 09-29
实例讲解各种数据库当前日期的标准写法 02-03
讲解数据库中行级转换成列级的应用案例 04-08
Oracle中怎样用自治事务保存日志表 04-11
初学者必读:oracle监听口令及监听器安全 07-16
数据库中判断一个字符串内是否含有中文 05-06
解析Oracle 准备开发的文件系统 Btrfs 09-01
Oracle 9i中自动撤销管理的优点分析 04-11
详细讲解oracle数据库灾难防护的核心技术 02-29
深入讲解游标类型为什么会产生数据检索 04-09
几种解决互联网应用程序开发的好方法 (1) 03-28
建立用户组保证Oracle数据库安全性 04-11
带你轻松了解Oracle数据库中审计的概念 09-29
在线日志文件都是active或current的现象 02-26
Oracle 9i应用COMPOSE和UNISTR创建沉音 07-07
教你删除oracle数据库中重复没用的数据 09-10
解析:oracle热备期间过量redo生成控制 11-15
在oracle数据库中移动数据文件的具体方法 08-04
不要忽视Oracle 10g STATSPACK新功 05-27
讲解Oracle数据库之中数据安全完全分析 07-07
返回首页 | 关于我们 | J网章程 | JSP空间合租 | 客服中心 | 免责声明 | 常见问题 | 参观机房
本站主机空间代理至厦门市华众网络科技有限公司
《中华人民共和国增值电信业务经营许可证》
编号:闽B2-20050079
@2005-2008福建JSP技术网 版权所有 闽ICP备05000928号
厦门(总部):13616026886 福州:0591-87655121
邮箱:admin@fjjsp.com 站长QQ,点击这里给我发消息