본문 바로가기
Programming/DataBase

[oracle] 테이블 전체 삭제

by 막이 2015. 5. 29.
select *
from (select case when object_type = 'VIEW' then 'view'
         when object_type = 'PROCEDURE' then 'procedure'
         when object_type = 'PROCEDURE' then 'function'
         when object_type = 'SEQUENCE' then 'sequence'
         when object_type = 'TYPE' then 'type'
         when object_type = 'TABLE' then 'table'
       end AS object_group
      , case --when object_type = 'VIEW' then 'drop view '||object_name||';'
          --when object_type = 'PROCEDURE' then 'drop procedure '||object_name||';'
          --when object_type = 'PROCEDURE' then 'drop function '||object_name||';'
          --when object_type = 'SEQUENCE' then 'drop sequence '||object_name||';'
          --when object_type = 'TYPE' then 'drop type '||object_name||';'
          when object_type = 'TABLE' then 'drop table '||object_name||';'
       end AS object_drop_sql
   from user_objects
   order by decode(object_type, 'VIEW', 0,
                  'PROCEDURE', 1,
                  'FUNCTION', 2,
                  'SEQUENCE', 3,
                  'TYPE', 4,
                  'TABLE', 5)
)
where object_drop_sql is not null;