본문 바로가기
MySQL

테이블 복사 , 초기화 TRUNCATE TABLE

by 소힌 2022. 2. 3.

[1] 테이블 복사 방법 

create table owners_copy Like owners;

insert into owners_copy select * from owners ; 

 

 

[2] 테이블 복사 방법 2 

create table owners_copy2 select * from owners ; // 행 값이 복사가 된다 

 

[3] 임시테이블 

create temporary table if not exists (동일 테이블이 없을 때만) temp_tabel (

tempId int primary key auro_increment ,

tempName varchar(10) 

); 

 

 

[4] 처음 만들었을 때의 상태로 초기화 

Truncate table table_name;