将XML文件转换为SQL数据库的自动化方法? [英] Automated way to convert XML files to SQL database?

查看:911
本文介绍了将XML文件转换为SQL数据库的自动化方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们遵循的模式是一堆XML文件,该模式本质上是序列化的数据库形式:

We have a bunch of XML files, following a schema which is essentially a serialised database form:

<table1>
   <column1>value</column1>
   <column2>value</column2>
</table1>
<table1>
   <column1>another value</column1>
   <column2>another value</column2>
</table1>
...

有没有一种非常简单的方法可以将其转换为SQL数据库?显然,我可以手动构造模式,识别所有表,字段等,然后编写脚本以将其导入.我只是想知道是否有任何工具可以使该过程的某些或全部自动化?

Is there a really easy way to turn that into an SQL database? Obviously I can manually construct the schema, identify all tables, fields etc, and then write a script to import it. I just wonder if there are any tools that could automate some or all of that process?

推荐答案

对于Mysql,请参见

For Mysql please see the LOAD XML SyntaxDocs.

对于您提供的XML,它应该无需任何其他XML转换即可工作,只需指定格式并使用匹配的列名称直接在数据库中定义表:

It should work without any additional XML transformation for the XML you've provided, just specify the format and define the table inside the database firsthand with matching column names:

LOAD XML LOCAL INFILE 'table1.xml'
    INTO TABLE table1
    ROWS IDENTIFIED BY '<table1>';

还有一个相关的问题:

对于Postgresql,我不知道.

For Postgresql I do not know.

这篇关于将XML文件转换为SQL数据库的自动化方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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