日期:2014-05-17 浏览次数:20761 次
#!bin/sh
su - oracle
sqlplus /nolog
conn usr/pwd <<EOF
set heading off;
set feedback off;
spool /oraclebak/dropobj.sql;
select 'Drop table '||table_name||' cascade constraints;' from all_tables where owner='usr';
select 'drop view ' || view_name||' cascade constraints;'||chr(13)||chr(10) from all_views where owner='usr';
select 'drop sequence ' || sequence_name||';'||chr(13)||chr(10) from all_sequences where sequence_owner='usr';
select 'drop procedure ' || object_name||';'||chr(13)||chr(10) from all_objects where object_type='PROCEDURE' and owner='usr';
select 'drop package ' || object_name||';'||chr(13)||chr(10) from all_objects where object_type='PACKAGE' and owner='usr';
spool off;
set heading on;
set feedback on;
EOF
DECLARE
V_SQL varchar2(200);
BEGIN
for del in (select t.OBJECT_TYPE,t.OBJECT_NAME from dba_objects t where t.OWNER = 'HH7YX') LOOP
begin
V_SQL := 'drop '
------解决方案--------------------
del.object_type
------解决方案--------------------
' '
------解决方案--------------------
del.object_name
------解决方案--------------------
';';
dbms_output.put_line(V_SQL);
EXECUTE IMMEDIATE V_SQL;
exception
when others then
null;
--dbms_output.put_line(sqlerrm);
end;
END LOOP;
END;