为 sql 2008 xml 批量加载生成模式
大家好,我必须将大型 xml 数据文件(其中一些大小为 500 mb)导入到 sql 2008 中。我计划使用 sqlxml 批量加载来实现同样的目的。
但是我只对 xml 数据文件的某些元素感兴趣,而不是每个元素。我的问题是:在架构文件中,我是否需要提及 xml 数据文件中存在的每个元素,或者仅提及我有兴趣加载的那些元素
第二个问题是:是否有任何工具可以自动生成这些元素用于 sqlxml 批量加载的模式文件,因为我对 xsd / xdr 知之甚少,
提前致谢
hey guys i have to import large sized xml data files (some of them 500 mb in size) into sql 2008. i plan to use sqlxml bulk load for the same.
however i am only interested in certain elements of the xml data file, not each and every element. my question is: in the schema file do i need to mention each and every element present in the xml data file or only those elements which i am interested in loading
second question is: is there any tool by which i can automate the generation of these schema files for sqlxml bulk load as i have very little knowledge of xsd / xdr
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在寻找其他东西时遇到了这个老问题,但无论如何我都会回答它,以供将来参考。
要忽略某些元素,您可以使用:
sql:mapped="false"
完全忽略节点,包括其子节点(请参阅sql:mapped (SQLXML 4.0))sql:is-constant="true"
忽略容器节点,但继续处理子节点(请参阅 使用 sql:is-constant 创建常量元素 (SQLXML 4.0))sql:overflow-field="OverflowColumnName"
写入未映射到额外列的所有内容(请参阅 sql:溢出字段 (SQLXML 4.0))要自动生成架构文件,您可以使用 xsd.exe 生成架构,但随后您必须自己添加关系,请参阅 MSDN 上的 XML 批量加载示例。我对其他工具一无所知,但我似乎记得一些对生成关系的工具的引用。
编辑我刚刚遇到这篇旧帖子如何从 XSD 文件创建数据库表?。当然,从
.xsd
生成架构比.xml
更进一步,但它会节省一些时间,也许这些相同的工具也可以从 XML 生成它? (除了 2008 年提到的这些工具之外,嘿,尝试一下总没有坏处。)它提到了这些工具:I ran into this old question looking for something else, but I will answer it anyway, for future reference.
To ignore certain elements, you can use:
sql:mapped="false"
to ignore a node totally, including its children (see sql:mapped (SQLXML 4.0))sql:is-constant="true"
to ignore a container-node, but continue processing the children (see Creating Constant Elements Using sql:is-constant (SQLXML 4.0))sql:overflow-field="OverflowColumnName"
to write everything you did not map to an extra column (see sql:overflow-field (SQLXML 4.0))Tot automate the generation of schema files, you can use
xsd.exe
to generate the schema, but then you will have to add relationships yourself, see the XML Bulk Load Examples on MSDN. I don't know anything about other tools, but I seem to remember some references to tools generating the relationships.Edit I just ran into this old post How can I create database tables from XSD files?. Of course generating schemas from
.xsd
is one step further than.xml
, but it will save some time, and maybe these same tools can also generate it from XML? (Besides these tools were mentioned in 2008, but hey, it never hurts to try.) It mentions these tools:您可以使用 XSD.exe 从 XML 数据文件创建架构。
You can use XSD.exe to create the schema from the XML data file.