테이블 스페이스 이동 (오라클, alter table)

테이블 및 인덱스에 대하여서도 현재의 테이블스페이스에서 다른 테이블 스페이스로 온라인상에서 이동 할수 있다.(기존에는 해당 테이블에 대하여 백업을 수행하고, 스키마를 생성 하고, 데이터 로딩 작업을 수행 했다.ddl-->imp>)



1. 테이블에 대한 테이블스페이스 이동 :

SQL> alter table move tablespace ;



alter table dept move tablespace tools ; (users --> tools)



SQL> select table_name, tablespace_name
2 from user_tables
3 where table_name like 'DEPT%'


TABLE_NAME TABLESPACE_NAME
------------------ ------------------------------
DEPT USERS
DEPT_1 USERS
DEPT_2 USERS
SQL> alter table dept_1 move tablespace tools;

Table altered.



SQL> select table_name, tablespace_name
2 from user_tables
3 where table_name like 'DEPT%'


TABLE_NAME TABLESPACE_NAME
------------------ ------------------------------
DEPT USERS
DEPT_1 TOOLS
DEPT_2 USERS


2. 인덱스에 대한 테이블스페이스 이동 : 인덱스를 Rebuild 한다

SQL> alter index rebuild tablespace < tablespace_name> ;



alter index pk_dept rebuild tablespace tools ; (users --> tools)



SQL> select index_name, tablespace_name
2 from user_indexes


INDEX_NAME TABLESPACE_NAME
------------------------------ ------------------------------
PK_DEPT TOOLS
PK_EMP USERS

SQL> alter index pk_dept rebuild tablespace users;

Index altered.

SQL> select index_name, tablespace_name
2 from user_indexes

INDEX_NAME TABLESPACE_NAME
------------------------------ ------------------------------
PK_DEPT USERS
PK_EMP USERS