insert 多条记录
如insert into a
select 'dd','ddd',000 union all
select 'sd',''fdsaf',111 union all
select ...
必须用union all么 ?有别的方法么?
如insert into a
select 'dd','ddd',000 union all
select 'sd',''fdsaf',111 union all
select ...
必须用union all么 ?有别的方法么?
如果没有重复的话 还能用 union
union 和 union all 的区别
union all : 不经过排序和合并
union: 重复的要合并和排序
union all:会把所有记录给union起来,不会去重
union:会经过排序,记录集中的重复数据只会保留一条。
使用union或union all时,被连接的结果集中的各个字段的数据类型必须一致。
insert into tb(col1,col2,col3)
values(col1_value,col2_value,col3_value);
go
用批量插入,就必须用union all 或者 union 实现了;