create table1 select * from table2 与 insert into table1 select * from table2的区别与用法
1、区别:
select * into table1 from table2 要求目标表存在;
create table1 select * from table2 要求目标表不存在,因为在插入时会自动创建。
2、作用:
select * into table1 from table2 一般用于还原表数据
create table1 select * from table2 一般用于备份表数据
1. 复制表结构及其数据:
create table table1 select * from table2
2. 只复制表结构:
create table table1 select * from table2 where 1=2;
或者:
create table table1 like table2
3. 只复制表数据:
如果两个表结构一样:
insert into table1 select * from table2
如果两个表结构不一样:
insert into table1(column1,column2...) select column1,column2... from table2