测试数据 -- 创建测试表1 CREATE TABLE `testtable1` ( `Id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, `UserId` INT(11) DEFAULT NULL, `UserName` VARCHAR(10) DEFAULT NULL, `UserType` INT(11) DEFAULT NULL, PRIMARY KEY (`Id`), UNIQUE KEY `IX_UserId` (`UserId`) ) ENG…
ado.net已经有了sqlBulkCopy, 但是那个用xml格式,网络传输数据量太大. 自己实现了一个,传输尽量少的字节. 性能没对比过,有需要的自己拿去测试. using System.Data.SqlClient; namespace RaywindStudio.DAL { /// <summary> /// MSSQL批量插入表 /// </summary> public static class SqlBulkInsert { private static bool i…
http://www.cnblogs.com/azhqiang/p/4050331.html 在进行数据库操作时, 我们经常会遇到批量向数据库中写入记录的情况. 在这里我提供3种操作方式:   1.  单条语句循环插入, 这是最笨的方法: for i := 0 to 100 do   ADOCommand1.Execute('IINSERT INTO .....')   //伪码, 只是说明意思   2.  多条语句批量插入, 将多条Insert语句拼成一条语句, 一次执行: for i :=…
mybatis oracle mysql 批量插入一.oracle的批量插入方式insert into db(id, zgbh, shbzh) select '1', '2', '3' from dual union all select '2', '3', '4' from dual union all select '3', '4', '5' from dual union all select '4', '5', '6' from dual union all select '5', '6…
参考资料:http://www.w3school.com.cn/sql/sql_union.asp   UNION:操作符用于合并两个或多个select语句的结果集.                 注意   union内部的select语句必须拥有相同的列数并且字段类型相同,且顺序相同. INSERT:  批量插入结果集                1. insert into table                 select x,y from A                 U…
批量插入100条记录 set nocount on declare @i int=1; while @i<=100 begin Insert into Client(id,ClientCode,ClientName,ClientGroup,stype,Contact,ClientTel,SendAddress) select @i+8,'C'+right('000000'+CAST(@i as varchar),6),'Customer'+CAST(@i as varchar),'B组','E帐…
1.有一个普通的表t_asset,只有2个字段id,ip 没有索引 2.当用insert into t_asset(id,ip) values(?,?),(?,?) 1200多条记录时,发现竟然用了30秒左右,不可能性能这么差啊 3.后来各种google,发现jdbc的连接串里,只配置了字符集啥也没配,默认是没有开启批量插入功能的 修改如下 jdbc:mysql://11.51.194.152:3358/test?rewriteBatchedStatements=true&useUnicode=…
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.Common;using System.Data.Entity;using System.Data.SqlClient;using System.Linq; namespace TY.Tools{ /// <summary> /// 批量插入 /// </summary&…
create  PROCEDURE insertinto as begindeclare @id int;set @id=1;while @id<10begininsert into person (id,name) values(@id,'123')set @id=@id+1endend 批量插入数据: 定义变量,执行循环,将int转化为varchar.例如:convert(varchar(10),@bmc) declare @name  varchar(50);declare @pwd va…
后面进行完善修改. /*批量插入数据*/ 这个比较完善.直接插入数据库表. INSERT INTO `goods_transverter` ( `code`,`es_id`,`barcode`, `name`) SELECT t.`妈宝条码`,t.`标识ID`,t.`商品条码`,t.`商品名称` FROM hbx.`商品数据` as t 查询华创的条码的配送价,采购价 ,),,),gb.`name` FROM hbx.`商品数据` as sp LEFT JOIN arm_changsha.goo…