从XML读取错误的数据到MYSQL

时间:2018-02-23 17:42:30

标签: mysql xml

我有一个XML文件,结构如下:

   <tickets>
       <ticket id='TKT*****'>
      <description>blah blah </description>
      <area>pdk</area>
      <severity>aaaaaaa</severity>
      <type>Defect</type>
      <tech>aaaaaaaa</tech>
      <part>aaaaaaa</part>
      <state>Closed</state>
      <disposition>aaaaaaaa</disposition>
      <flavor>aaaaaa</flavor>
      <link>pdm</link>
      <vendor>TSMC</vendor>
      <date>2010-06-09</date>
      </ticket>
</tickets>

我正在尝试使用HiediSQL将其加载到MySQL表中。我创建了一个临时表:

CREATE TABLE TEST_TABLE(
    `id` VARCHAR(20),
`description` TEXT,
`area` TEXT , 
`severity` TEXT  ,
`type` TEXT , 
`tech` TEXT  ,
`part` TEXT , 
`state` TEXT  ,
`disposition` TEXT ,
`flavor` TEXT ,
`link` TEXT  ,
`vendor` TEXT ,
`date` DATE  ,
`assign` DATE ,
PRIMARY KEY (`id`));

 LOAD XML LOCAL INFILE 'C:\Users\nxf33836\Downloads\pdm\pdm_open_2011-02-14.xml'
 INTO TABLE TEST_TABLE ;

行未被识别,所有内容都填入第1列,如下图所示,我尝试使用:

 LOAD DATA LOCAL INFILE 'C:aaaaaaaaaaaaaaaa/pdm_open_2011-02-14.xml'
 INTO TABLE TEST_TABLE(id,description,area,severity,type,tech,part,state,disposition,flavor,link,vendor,date,assign)
 ROWS IDENTIFIED BY '<ticket>' ;

但它给出了语法错误。我也试过

  LOAD DATA LOCAL INFILE 'C:aaaaaaaaaaaaaaaa/pdm_open_2011-02-14.xml'
 INTO TABLE TEST_TABLE(id,description,area,severity,type,tech,part,state,disposition,flavor,link,vendor,date,assign)
    ROWS IDENTIFIED BY 'ticket' ;

enter image description here

我在这里缺少什么?

0 个答案:

没有答案