테이블명 (1)

테이블 백업을 할때에 export / import 를 이용할 수도 있지만 단순하게 rename 명령어를 이용할 수도 있습니다. 또한 create ~ as select ~ 를 이용할 수도 있습니다.

하지만 오늘은 테이블 명을 변경하고 새로 테이블을 생성함으로써 백업을 할 수 있는 방법을 소개하도록 하겠습니다. 참고로 이 방법은 blob데이타가 많은 경우에 상당히 유용합니다.


Step by Step

1) Query table name and index names linked to the table you want to backup

2) Rename table name

3) Rename indexes' name ( if specified explicitly when it is created )

4) Rename constraints' name ( if specified explicitly when it is created )

4) Use the same DDL used to create the renamed table


※ This way is very simple and fast then using "create table ~ as select * from ~" statement when the table has a huge blob data.



1) 변경하고자하는 테이블에 어떤 인덱스들이 있는지 조회합니다.

SQL > select index_name, table_name from user_indexes;


2) 테이블명을 변경합니다.

SQL > rename old_table to new_table;


3) 인덱스명을 변경합니다. ( 인덱스명이 자동생성된 것이 아닌 경우에만 )

SQL > alter index pk_old_table rename to pk_new_table;


4) 제약사항명을 변경합니다. ( 제약사항명이 자동생성된 것이 아닌 경우에만 )

SQL > select * from user_cons_columns where table_name='{table_name};

SQL > alter table {table name} rename constraint {constraint name} to {new constraint name}


5) 기존 테이블을 생성했던 DDL을 사용하여 테이블을 새로 생성합니다.

SQL > create table .........