Renameμ μ΄μ©ν ν μ΄λΈ λ°±μ ( Table Backup using Renaming )
ν μ΄λΈ λ°±μ μ ν λμ 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 .........