DATABASE/Mysql&MariaDB

Mariadb Table 복사

Mr.Kang 2019. 9. 25. 10:13

1. 테이블복사(테이블 스키마 복사)

테이블 스키마복사
Create Table new_table like old_table;

새로 생성되는 테이블이 없는경우에만 복사
Create Table IF NOT EXISTS new_table like old_table;

 

2. 테이블 스키마와 데이터 복사

기존 테이블에 'Primary Key' 또는 'auto_incremen'는 설정되지 않고 복사 된다.
Create Table new_table ( select * from old_table );

 

3. 데이터만 복사

Insert Into destination_table ( select * form source_table);