将XML导入MySQL关系表

时间:2016-10-18 05:37:22

标签: mysql xml relational-database

我正在尝试将XML导入SQL数据库,但是我在将子元素导入SQL服务器时遇到问题

<bug>
  <bug_id>925710</bug_id>

  <creation_ts>2013-10-11 05:24:10 -0700</creation_ts>
  <short_desc>Update conditionalForwardWithUrlbarWidth to reflect reality</short_desc>
  <classification>Client Software</classification>
  <product>Firefox</product>
  <component>Theme</component>
  <version>Trunk</version>
  <rep_platform>All</rep_platform>
  <op_sys>Linux</op_sys>
  <bug_status>RESOLVED</bug_status>
  <resolution>FIXED</resolution>

  <long_desc isprivate="0">
    <commentid>7949860</commentid>
    <attachid>815815</attachid>
    <who name="Dão Gottwald [:dao]">dao</who>
    <bug_when>2013-10-11 05:24:10 -0700</bug_when>
    <thetext>Created attachment 815815 patch . The forward icon is now 18 instead of 24 pixels wide.</thetext>
  </long_desc>

  <long_desc isprivate="0">
    <commentid>7950323</commentid>
    <who name="Dão Gottwald [:dao]">dao</who>
    <bug_when>2013-10-11 08:04:54 -0700</bug_when>
    <thetext>http://hg.mozilla.org/projects/ux/rev/f0b25f2217ab</thetext>
  </long_desc>

  <long_desc isprivate="0">
    <commentid>8092710</commentid>
    <who name=":Gijs Kruitbosch">gijskruitbosch+bugs</who>
    <bug_when>2013-11-18 12:39:15 -0800</bug_when>
    <thetext>https://hg.mozilla.org/mozilla-central/rev/f0b25f2217ab</thetext>
  </long_desc>
</bug>

我正在使用

将XML导入SQL数据库
LOAD XML LOCAL INFILE "D:\\test.xml"
INTO TABLE mytable
ROWS IDENTIFIED BY '<bug>';

但是我无法找到一种创建关系表的方法,该关系表将bug_id引用到注释中,就像我使用时一样

LOAD XML LOCAL INFILE "D:\\test.xml"
INTO TABLE mytable
ROWS IDENTIFIED BY '<long_desc>';

显然无法访问bug_id。

非常感谢任何帮助

0 个答案:

没有答案