그 때 그 때 생각해서 하기 귀찮으니 적어두기
select 'alter ' || decode(grp_no,'01','table ' || table_name ,'00','index ' || index_name) || ' move 'from (select a.table_name,b.index_name,grouping(a.table_name) || grouping(b.index_name) as grp_no -- table과 index를 구분하게 함from user_tables a , user_indexes bwhere a.table_name = b.table_namegroup by rollup(a.table_name,b.index_name) -- table과 index를 결합한곳에서 table 부분만 따로 생성함order by table_name , grouping(a.table_name) || grouping(b.index_name) desc -- table이 인덱스보다 위로 오게 함) awhere grp_no != '11' -- table과 index전체 합계는 제외함;
'오라클DBMS > SQL,PL/SQL' 카테고리의 다른 글
[오라클] LOB TABLESPACE MOVE 쿼리 생성 (0) | 2013.04.03 |
---|---|
[오라클/PLSQL] 테이블 이름이 변경되는 DML문장 (0) | 2013.03.22 |
[오라클] 쿼리가 느려요? DB_LINK 테이블 서브쿼리로 JOIN (0) | 2012.03.22 |
[UPDATE] JOIN-VIEW를 이용한 UPDATE시 KEY 대입이 안된다면 (0) | 2011.10.11 |
[SQLPLUS/Shell Script] 쉘스크립트 쿼리 사용시 (0) | 2009.12.14 |