从XML文件中的大数据迁移到数据库 [英] migrate the large data from xml file to the database

查看:283
本文介绍了从XML文件中的大数据迁移到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问:

我面临着以下问题两个星期前,我不知道如何处理它走的是性能问题,数据的完整性考虑。

I face the following problem two weeks ago , and i don't know how to handle it taking the performance issues , the data integrity in consideration.

我做的是:

我想将数据从 XML文件迁移以类似的表在我的数据库

I wanna to migrate the data from the XML file to its similar tables in my database.

例如:


  • 我有两个节点(XML文件):

  • i have two nodes (XML file):

课程教师

两个表(数据库)

课程教师

我允许用户将XML文件上传到我的服务器上的文件夹,我开始读取XML文件和数据插入到我的数据库。

I allow the user to upload the XML file to a folder on my server and i begin to read the XML file and insert the data into my database .

问题是:

如果在插入操作过程中的一些故障发生时,我想删除所有表中的所有插入的记录。(或回滚)。

if some failure happens during the insertion operation , i wanna to delete all the inserted records in all tables.(or roll back).

我开始思考交易,每个实体的插入将通过交易进行,但我面对两个问题:

I begin to think about transaction , the insertion of each entity will be performed through transaction but i face two problems:


  1. 我应该把所有的实体都插入在一个事务中或
    一个事务中的一个实体?(所有实体数据必须全部插入或没有插入的话)对每个上传

  1. Should i put all insertions of all entities in one transaction or one entity by one in transaction?(all entities data must be all inserted or no insertion at all )for each uploader.

当我有记录的数量庞大的说(1500记录)。以下
例外出现:

When i have huge number of records say(1500 record).the following exception appear:

这IfxTransaction已完成;它不再可用,无
1修复它。

This IfxTransaction has completed; it is no longer usable,no one fixes it.

我的领队告诉我不要使用事务,因为它会
锁定表和许多用户使用这些表。他想一些其他的
机制。

My team leader told me not to use the transaction , because it will lock the tables and many users use those tables. he wanna some other mechanism .

请我想解决我的问题(详细的说明),如何处理这种情况下,保持性能问题和数据的完整性和一致性。

please i wanna a solution to my problem(detailed explanation), How to handle this case and maintain the performance issues and the data integrity and consistency .

推荐答案

我建议使用SqlBulkCopy的。你可以谷歌,阅读这些文章2:

I would suggest using SqlBulkCopy. You can google, or read these 2 articles:


  1. http://blogs.msdn.com/b/nikhilsi/archive/2008/06/11/bulk-insert-into-sql-from-c-app.aspx

  2. http://www.dotnetcurry.com/ShowArticle.aspx?ID=323

  1. http://blogs.msdn.com/b/nikhilsi/archive/2008/06/11/bulk-insert-into-sql-from-c-app.aspx
  2. http://www.dotnetcurry.com/ShowArticle.aspx?ID=323

这篇关于从XML文件中的大数据迁移到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆