电脑技术学习

删除一个Oracle用户的对象

dn001

  
--删除某个用户下的对象
set heading off;
set feedback off;
spool c:dropobj.sql;

prompt --Drop tables
select 'drop table ' table_name ';'chr(13)chr(10) from user_tables;
;
prompt --Drop view
select 'drop view ' view_name';'chr(13)chr(10) from user_views;

prompt --Drop sequence
select 'drop sequence ' sequence_name';'chr(13)chr(10) from user_sequences;

prompt --Drop function
select 'drop function ' object_name';'chr(13)chr(10) from user_objects; where object_type='FUNCTION';

prompt --Drop procedure
select 'drop procedure ' object_name';'chr(13)chr(10) from user_objects; where object_type='PROCEDURE';

prompt --Drop package
select 'drop package ' object_name';'chr(13)chr(10) from user_objects; where object_type='PACKAGE';

spool off;
set heading on;
set feedback on;

@@c:dropobj.sql;
host del c:dropobj.sql;