oracle删除当前用户所有表,视图,存储过程等

来源:转载


--删除序列declare cursor cur is select 'drop sequence ' || sequence_name as a from user_sequences;beginfor i in cur loopexecute immediate i.a;end loop;end;
--删除表declare cursor cur is select 'drop table ' || table_name as a from user_tables;beginfor i in cur loopexecute immediate i.a;end loop;end;
--删除视图declare cursor cur is select 'drop view ' || view_name as a from user_views;beginfor i in cur loopexecute immediate i.a;end loop;end;

--删除存储过程declare cursor cur is select 'drop procedure ' || object_name as a from user_objecst where object_type='PROCEDURE';beginfor i in cur loopexecute immediate i.a;end loop;end;
--删除方法declare cursor cur is select 'drop function ' || object_name as a from user_objects where object_type='FUNCTION';beginfor i in cur loopexecute immediate i.a;end loop;end;
--删除包declare cursor cur is select 'drop package' || object_name as a from user_objects where object_type='PACKAGE';beginfor i in cur loopexecute immediate i.a;end loop;end;
--删除所有declare cursor cur is select 'drop '|| object_type || ' ' || object_name || '  cascade constraints' as a from user_objects where object_type not in ('INDEX', 'LOB');beginfor i in cur loopexecute immediate i.a;end loop;end;





分享给朋友:
您可能感兴趣的文章:
随机阅读: