先存放好dropobj.sql 文件 然后登录需要删除的用户
删除前最好备份一下:(备份是在cmd中进行的)
C:Userspanfu>exp file=d:expall.dmp log=expall.log full=y
Export: Release 10.2.0.1.0 - Production on 星期五 11月 11 11:27:57 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
用户名: /@DBName as sysdba
执行一下命令:
SQL> show user;
查看是否是当前需要删除的用户
(用sqlplus登录如果密码错了会登录到sys用户,一定要注意不要删错用户,不然后悔晚矣~~)
SQL>@D:dropobj.sql
等待执行完成后,
SQL>@D:dropobjall.sql
删除完成~~
复制以下内容存放在d:dropobj.sql 中:
set heading off;
set feedback off;
spool D:dropobjall.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;