[英]Copying large amounts of data into a SQL CE database
If I have a large amount of data in memory, what is the best way to copy it into a SQL CE table? 如果内存中有大量数据,将其复制到SQL CE表的最佳方法是什么? The current technology stack is C#, ADO.net, and SQL CE.
当前的技术堆栈是C#,ADO.net和SQL CE。
My initial idea was to do one INSERT statement for each row of data, but this is time-consuming. 我最初的想法是为每行数据执行一个INSERT语句,但这很耗时。 Is there an easier way?
有更容易的方法吗?
Steve Lasker has a great code sample demoing this with different methods, but the best method (by far) is SqlCeResultSet . 史蒂夫·拉斯克(Steve Lasker)有一个很棒的代码示例,用不同的方法对此进行了演示,但到目前为止,最好的方法是SqlCeResultSet 。
Here is a blog post from Steve with some good powerpoints on this subject. 这是史蒂夫(Steve )的博客文章,在该主题上有一些不错的观点。
The first thing that popped into my head was to do a sync/merge with a desktop or server database, though that doesn't sound like it really fits your needs. 突然想到的第一件事就是与桌面或服务器数据库进行同步/合并,尽管听起来并不像它真正满足您的需求。 So here is my second thought:
所以这是我的第二个想法:
BULK INSERT table_name FROM data_file 批量插入table_name FROM data_file
I am not sure if it is supported in your version of SQL CE (though it appears to be supported in 3.5 SP1 from what I can tell on the MSDN pages). 我不确定您的SQL CE版本是否支持它(尽管从MSDN页面上可以看出,它似乎在3.5 SP1中受支持)。 http://msdn.microsoft.com/en-us/library/ms188365.aspx
http://msdn.microsoft.com/en-us/library/ms188365.aspx
You could also disable any indexes on the table while inserting the data to speed things up, then enable/rebuild the index once you are done inserting. 您还可以在插入数据时禁用表上的任何索引,以加快处理速度,然后在完成插入后启用/重建索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.