首页 > 代码库 > sql - 批量插入数据

sql - 批量插入数据

  • 直接构造
insert into t (c1, c2, c3) values (1, 1, 1), (2, 2, 2)
  • 使用UNION
insert into t (c1, c2, c3) (select a1, a2, a3) union all (select b1, b2, b3)

 

  • 利用查询结果
insert into t (c1, c2, c3) (select a1, a2, a3 from t2)