ํ…Œ์ด๋ธ” ๋ฐฑ์—…์„ ํ• ๋•Œ์— 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 .........