码迷,mamicode.com
首页 > 数据库 > 详细

Oracle 删除某个用户下的所有对象,执行需谨慎

时间:2018-07-18 14:10:41      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:nts   ack   新建   pack   proc   lte   traints   seq   host   

Oracle 删除某个用户下的所有对象,执行需谨慎

在PL/sql中,点"新建"->"命令窗口"->粘贴后直接执行

--删除某个用户下的对象
set heading off;
set feedback off;
spool d:/dropobj.sql;
prompt --Drop constraint
select ‘alter table ‘||table_name||‘ drop constraint ‘||constraint_name||‘ ;‘ from user_constraints where constraint_type=‘R‘;
prompt --Drop tables
select ‘drop table ‘||table_name ||‘;‘ from user_tables;

prompt --Drop view
select ‘drop view ‘ ||view_name||‘;‘ from user_views;

prompt --Drop sequence
select ‘drop sequence ‘ ||sequence_name||‘;‘ from user_sequences;

prompt --Drop function
select ‘drop function ‘ ||object_name||‘;‘ from user_objects where object_type=‘FUNCTION‘;

prompt --Drop procedure
select ‘drop procedure ‘||object_name||‘;‘ from user_objects where object_type=‘PROCEDURE‘;

prompt --Drop package
prompt --Drop package body
select ‘drop package ‘|| object_name||‘;‘ from user_objects where object_type=‘PACKAGE‘;

prompt --Drop database link
select ‘drop database link ‘|| object_name||‘;‘ from user_objects where object_type=‘DATABASE LINK‘;

spool off;
set heading on;
set feedback on;

@@d:/dropobj.sql;
host del d:/dropobj.sql;

Oracle 删除某个用户下的所有对象,执行需谨慎

标签:nts   ack   新建   pack   proc   lte   traints   seq   host   

原文地址:https://www.cnblogs.com/li-sx/p/9328428.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!