Databases
MySQL 테이블 복사
duraboys
2018. 4. 30. 16:58
테이블의 설정 그대로 복사
Create Table new_table like old_table
테이블의 구조와 함께 데이터도 함께 복사
Create Table new_table ( select * from old_table )
Insert Into destination_table ( select * form source_table)
참고 ==> 대상 테이블의 컬럼 중에 자동 증가 값 설정 이 된 컬럼이 있을 경우 해당 컬럼에 데이터 입력시 중복된 데이터가 있으면 오류 발생.
응용 ==> Insert Into destination_table (column_a, column_b) (select a, b from source_table) 원하는 필드의 데이터만 복사가 가능하다.