create table select from과 insert into table select from의 차이점

835 단어 데이터베이스
create table select frominsert into table select from는 모두 표를 복제하는 데 사용되는데 이들의 주요 차이점은 다음과 같다.
  • create table select from는 삽입할 때 자동으로 생성되기 때문에 목표표가 존재하지 않습니다.
  • insert into table select from는 목표표가 존재하도록 요구하고 복사 삽입에 해당한다.
  • 백업 테이블 데이터: create table tmp_article_info as select * from article_info
  • 복원 테이블 데이터: insert into tmp_article_info select * from article_info
  • 테이블 구조만 복제: create table tmp_article_info as select * from article_info where 1=0
  • 테이블 데이터만 복제(두 테이블 구조가 완전히 같으면): insert into tmp_article_info select * from article_info
  • 테이블 데이터만 복제(두 테이블 구조가 다르거나 부분 복제): insert into tmp_article_info (column1,column2...) select column1,column2 from article_info
  • 좋은 웹페이지 즐겨찾기