Dropping all user tables/sequences in Oracle

BEGIN 
 
 
--Bye Sequences! 
 
FOR i IN(SELECT us.sequence_name 
             
FROM USER_SEQUENCES us) LOOP 
   
EXECUTE IMMEDIATE 'drop sequence '|| i.sequence_name ||''; 
 
END LOOP; 
 
 
--Bye Tables! 
 
FOR i IN(SELECT ut.table_name 
             
FROM USER_TABLES ut) LOOP 
   
EXECUTE IMMEDIATE 'drop table '|| i.table_name ||' CASCADE CONSTRAINTS '; 
 
END LOOP; 
 
END; 

 

 

--bye object

begin
FOR i IN(SELECT ut.object_name,ut.object_type
              FROM user_objects ut where ut.object_type in  ('PROCEDURE','PACKAGE','PACKAGE BODY','VIEW','FUNCTION') ) LOOP
    EXECUTE IMMEDIATE 'drop '||i.object_type||' '|| i.object_name ;
   
  END LOOP;

end;

posted on 2012-02-02 01:49  weaver_chen  阅读(260)  评论(0编辑  收藏  举报