如何装入巨大的(但简单)的分层的XML文件导入到SQL表 [英] How to load huge (but simple) hierarchical XML file into an SQL table

查看:243
本文介绍了如何装入巨大的(但简单)的分层的XML文件导入到SQL表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常大的(2.5GB,5500万节点)以下格式的XML文件:

I have a very large (2.5GB, 55 million node) XML file with the following format:

<TopNode>
    <Item id = "Something">
         <Link>A link</Link>
         <Link>Another link</Link>
         <Link>One More Link</Link>
    </Item>
    <Item id = "Something else">
         <Link>Some link</Link>
         <Link>You get the idea</Link>
    </Item>
  </TopNode>

我想这个扁平化到下列SQL表:

I want to flatten this into the following SQL table:

 -----------------------------------------
 |  Item          |          Link        |
 -----------------------------------------
 | Something      |  A link              |
 | Something      |  Another link        |
 | Something      |  One More Link       |
 | Something Else |  Some Link           |
 | Something Else |  You get the idea    |
 |----------------|----------------------|

我使用SQL2008,如果有差别。

I'm using SQL2008, if that makes a difference.

什么是最简单,最有效的方式(pferably使用SQL Server / .NET堆栈$ P $)从A点到B点,同时要注意所涉及的文件的大小?

What's the simplest, most efficient way (preferably using the SQL Server/.NET stack) to get from point A to point B, keeping in mind the size of the file involved?

推荐答案

我会使用的 XML大容量加载。这是一个很好的方法,因为它没有在整个文档中读取一次,它流吧。这也是相当快,并保持你与基于SQL Server工具坚持的要求。

I would use the XML Bulk Load. This is a nice approach because it doesn't read in the entire document at once, it streams it. It's also quite fast and keeps to your requirement of sticking with an SQL Server based tool.

这篇关于如何装入巨大的(但简单)的分层的XML文件导入到SQL表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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