sq将一张表的数据导入到另外一张表数据需要考虑几种情况
1. 将一张表的全部数据导入到新表:
create table 新表 (select * from 来源表);
create table `new_table` (select * from `origin_table`);
2.将一张表数据根据需要的字段导入到新表,注意:这里新创建的表只有源表指定的字段,并不是源表的表结构中所有字段
create table 新表 (select 字段1,字段2 from 来源表);
create table `new_table` (select `id`, `name` from `origin_table`);
3.两张表结构完全一致,将表1全部数据导入到表2中
insert into 目标表 select * from 来源表;
insert into `target_table` select * from `origin_table`;
4.两张表结构完全一致,将表1指定字段数据导入到表2指定字段中
insert into 目标表(字段1,字段2)select 字段1,字段2 from 来源表;
insert into `target_table` (`id`, `name`) select `id`, `name` from `origin_table`;
5.根据筛选条件导入数据
create table '新表' (select * from '来源表' where 1 = 1 and '字段1' = '值' and '字段2' = '值');
create table `new_table` (select * from 'origin_table' where 1 = 1 and 'able_status' = 'ABLE' and `delete_status` = 'UNDELETE');
insert into '目标表' select * f