我試圖從這個XML文件導入到我的phpMyAdmin MySQL數據庫表中爲本地開發目的的數據(這是由管理員輸出給我)。除了我不知道該怎麼做。如何將這個XML數據導入到MySQL數據庫表中?
我查看了LOAD XML INFILE
查詢,將XML加載到我在本地數據庫中構建的表中的一個表中。然而,當我試圖通過查詢這樣做要麼
LOAD XML INFILE 'D://Secondary/wamp64/tmp/Part_Info.xml'
INTO TABLE dbtest.part_no
ROWS IDENTIFIED BY '<Row>'
OR
LOAD XML INFILE 'D://Secondary/wamp64/tmp/Part_Info.xml'
INTO TABLE dbtest.part_no
ROWS IDENTIFIED BY '<Data>'
桌旁站到處都洋溢着NULL值。 我認爲這個數據不是LOAD XML INFILE
工作所需的格式。 (如this question here所述)。
我該如何將這些數據導入到我的MySQL數據庫表中?
以下是需要導入的數據。
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>ANKUR PRAKASH</Author>
<LastAuthor>Shubham Mehta</LastAuthor>
<Created>2016-06-10T10:48:33Z</Created>
<LastSaved>2016-06-10T16:23:58Z</LastSaved>
<Version>16.00</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>4455</WindowHeight>
<WindowWidth>15345</WindowWidth>
<WindowTopX>0</WindowTopX>
<WindowTopY>0</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s62">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>
<Interior/>
<NumberFormat ss:Format="0"/>
<Protection/>
</Style>
<Style ss:ID="s63">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>
<Interior/>
<NumberFormat ss:Format="@"/>
<Protection/>
</Style>
<Style ss:ID="s64">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Arial" ss:Bold="1"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s65">
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"
ss:Bold="1"/>
</Style>
</Styles>
<Worksheet ss:Name="mltvwallinfotbl">
<Table ss:ExpandedColumnCount="12" ss:ExpandedRowCount="2001" x:FullColumns="1"
x:FullRows="1" ss:DefaultRowHeight="15">
<Column ss:StyleID="s62" ss:AutoFitWidth="0"/>
<Column ss:StyleID="s63" ss:AutoFitWidth="0" ss:Width="92.25"/>
<Column ss:StyleID="s63" ss:AutoFitWidth="0" ss:Width="102"/>
<Column ss:StyleID="s63" ss:AutoFitWidth="0" ss:Width="52.5"/>
<Column ss:StyleID="s63" ss:AutoFitWidth="0" ss:Width="180.75"/>
<Column ss:StyleID="s63" ss:AutoFitWidth="0" ss:Width="84.75"/>
<Column ss:StyleID="s63" ss:AutoFitWidth="0" ss:Width="35.25"/>
<Column ss:StyleID="s63" ss:AutoFitWidth="0" ss:Width="143.25"/>
<Column ss:StyleID="s63" ss:AutoFitWidth="0" ss:Width="67.5"/>
<Column ss:StyleID="s63" ss:AutoFitWidth="0" ss:Width="72"/>
<Column ss:StyleID="s63" ss:AutoFitWidth="0" ss:Width="90.75"/>
<Column ss:AutoFitWidth="0" ss:Width="81.75"/>
<Row ss:AutoFitHeight="0">
<Cell ss:StyleID="s64"><Data ss:Type="String">#</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Part #</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Mfr. Part #</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Mfr. #</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Part Description</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Prime Part #</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">PMA</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Key Word</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Part Type</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Planning Type</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Reference Status</Data></Cell>
<Cell ss:StyleID="s65"><Data ss:Type="String">Inventory Status</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="Number">1</Data></Cell>
<Cell><Data ss:Type="String">444-00522-700</Data></Cell>
<Cell><Data ss:Type="String">444-00522-700</Data></Cell>
<Cell><Data ss:Type="String">50010000</Data></Cell>
<Cell><Data ss:Type="String">INDICATOR,OXYG. HIGH PRESSURE</Data></Cell>
<Cell><Data ss:Type="String">444-00522-700</Data></Cell>
<Cell><Data ss:Type="String">No</Data></Cell>
<Cell ss:Index="9"><Data ss:Type="String">Component</Data></Cell>
<Cell><Data ss:Type="String">None</Data></Cell>
<Cell><Data ss:Type="String">Active</Data></Cell>
<Cell ss:Formula="=RANDBETWEEN(0,100)"><Data ss:Type="Number">0</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="Number">2</Data></Cell>
<Cell><Data ss:Type="String">444-01095-000</Data></Cell>
<Cell><Data ss:Type="String">444-01095-000</Data></Cell>
<Cell><Data ss:Type="String">50011658</Data></Cell>
<Cell><Data ss:Type="String">BELLOWS</Data></Cell>
<Cell><Data ss:Type="String">444-01095-000</Data></Cell>
<Cell><Data ss:Type="String">No</Data></Cell>
<Cell ss:Index="9"><Data ss:Type="String">Expendable</Data></Cell>
<Cell><Data ss:Type="String">Reorder Level</Data></Cell>
<Cell><Data ss:Type="String">Active</Data></Cell>
<Cell ss:Formula="=RANDBETWEEN(0,100)"><Data ss:Type="Number">0</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="Number">3</Data></Cell>
<Cell><Data ss:Type="String">444-01096-000</Data></Cell>
<Cell><Data ss:Type="String">444-01096-000</Data></Cell>
<Cell><Data ss:Type="String">50011658</Data></Cell>
<Cell><Data ss:Type="String">UNION</Data></Cell>
<Cell><Data ss:Type="String">444-01096-000</Data></Cell>
<Cell><Data ss:Type="String">No</Data></Cell>
<Cell ss:Index="9"><Data ss:Type="String">Expendable</Data></Cell>
<Cell><Data ss:Type="String">Reorder Level</Data></Cell>
<Cell><Data ss:Type="String">Active</Data></Cell>
<Cell ss:Formula="=RANDBETWEEN(0,100)"><Data ss:Type="Number">87</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="Number">4</Data></Cell>
<Cell><Data ss:Type="String">444-01298-400</Data></Cell>
<Cell><Data ss:Type="String">444-01298-400</Data></Cell>
<Cell><Data ss:Type="String">50010000</Data></Cell>
<Cell><Data ss:Type="String">ELECTRONIC PR SENSOR MODULE</Data></Cell>
<Cell><Data ss:Type="String">444-01298-400</Data></Cell>
<Cell><Data ss:Type="String">No</Data></Cell>
<Cell ss:Index="9"><Data ss:Type="String">Component</Data></Cell>
<Cell><Data ss:Type="String">None</Data></Cell>
<Cell><Data ss:Type="String">Active</Data></Cell>
<Cell ss:Formula="=RANDBETWEEN(0,100)"><Data ss:Type="Number">58</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="Number">5</Data></Cell>
<Cell><Data ss:Type="String">444-01298-800</Data></Cell>
<Cell><Data ss:Type="String">444-01298-800</Data></Cell>
<Cell><Data ss:Type="String">50011658</Data></Cell>
<Cell><Data ss:Type="String">PR.SENSR</Data></Cell>
<Cell><Data ss:Type="String">444-01298-400</Data></Cell>
<Cell><Data ss:Type="String">No</Data></Cell>
<Cell ss:Index="9"><Data ss:Type="String">Component</Data></Cell>
<Cell><Data ss:Type="String">None</Data></Cell>
<Cell><Data ss:Type="String">Active</Data></Cell>
<Cell ss:Formula="=RANDBETWEEN(0,100)"><Data ss:Type="Number">69</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="Number">6</Data></Cell>
<Cell><Data ss:Type="String">444-01300-300</Data></Cell>
<Cell><Data ss:Type="String">444-01300-300</Data></Cell>
<Cell><Data ss:Type="String">50011658</Data></Cell>
<Cell><Data ss:Type="String">VALVE</Data></Cell>
<Cell><Data ss:Type="String">444-01300-300</Data></Cell>
<Cell><Data ss:Type="String">No</Data></Cell>
<Cell ss:Index="9"><Data ss:Type="String">Expendable</Data></Cell>
<Cell><Data ss:Type="String">None</Data></Cell>
<Cell><Data ss:Type="String">Active</Data></Cell>
<Cell ss:Formula="=RANDBETWEEN(0,100)"><Data ss:Type="Number">22</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="Number">7</Data></Cell>
<Cell><Data ss:Type="String">443W5809JA078</Data></Cell>
<Cell><Data ss:Type="String">443W5809JA078</Data></Cell>
<Cell><Data ss:Type="String">50010001</Data></Cell>
<Cell><Data ss:Type="String">CARPET</Data></Cell>
<Cell><Data ss:Type="String">443W5809JA078</Data></Cell>
<Cell><Data ss:Type="String">No</Data></Cell>
<Cell ss:Index="9"><Data ss:Type="String">Expendable</Data></Cell>
<Cell><Data ss:Type="String">None</Data></Cell>
<Cell><Data ss:Type="String">Active</Data></Cell>
<Cell ss:Formula="=RANDBETWEEN(0,100)"><Data ss:Type="Number">48</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="Number">8</Data></Cell>
<Cell><Data ss:Type="String">443W5809JA079</Data></Cell>
<Cell><Data ss:Type="String">443W5809JA079</Data></Cell>
<Cell><Data ss:Type="String">50010001</Data></Cell>
<Cell><Data ss:Type="String">CARPET</Data></Cell>
<Cell><Data ss:Type="String">443W5809JA079</Data></Cell>
<Cell><Data ss:Type="String">No</Data></Cell>
<Cell ss:Index="9"><Data ss:Type="String">Expendable</Data></Cell>
<Cell><Data ss:Type="String">None</Data></Cell>
<Cell><Data ss:Type="String">Active</Data></Cell>
<Cell ss:Formula="=RANDBETWEEN(0,100)"><Data ss:Type="Number">98</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="Number">9</Data></Cell>
<Cell><Data ss:Type="String">443W7000-7VG</Data></Cell>
<Cell><Data ss:Type="String">443W7000-7VG</Data></Cell>
<Cell><Data ss:Type="String">50010001</Data></Cell>
<Cell><Data ss:Type="String">KICKSTRIP</Data></Cell>
<Cell><Data ss:Type="String">443W7000-7VG</Data></Cell>
<Cell><Data ss:Type="String">No</Data></Cell>
<Cell ss:Index="9"><Data ss:Type="String">Expendable</Data></Cell>
<Cell><Data ss:Type="String">None</Data></Cell>
<Cell><Data ss:Type="String">Active</Data></Cell>
<Cell ss:Formula="=RANDBETWEEN(0,100)"><Data ss:Type="Number">25</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="Number">10</Data></Cell>
<Cell><Data ss:Type="String">443W7000-7WD</Data></Cell>
<Cell><Data ss:Type="String">443W7000-7WD</Data></Cell>
<Cell><Data ss:Type="String">50010001</Data></Cell>
<Cell><Data ss:Type="String">KICKSTRIP</Data></Cell>
<Cell><Data ss:Type="String">443W7000-7WD</Data></Cell>
<Cell><Data ss:Type="String">No</Data></Cell>
<Cell ss:Index="9"><Data ss:Type="String">Expendable</Data></Cell>
<Cell><Data ss:Type="String">None</Data></Cell>
<Cell><Data ss:Type="String">Active</Data></Cell>
<Cell ss:Formula="=RANDBETWEEN(0,100)"><Data ss:Type="Number">2</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Unsynced/>
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<Selected/>
<TopRowVisible>75</TopRowVisible>
<LeftColumnVisible>2</LeftColumnVisible>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>107</ActiveRow>
<ActiveCol>4</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<ss:DocumentProperties>
<ss:Author>Ramco Systems Ltd</ss:Author>
<ss:LastAuthor>Ramco Systems Ltd</ss:LastAuthor>
<ss:Created>Friday, June 10, 2016</ss:Created>
</ss:DocumentProperties>
</Workbook>
注:我不是在尋找一個數據庫表,專門適合在這個數據我只是想在這個.XML文件將數據存儲到我的本地SQL數據庫表。你可以自由地假設任何適合你的答案並解決問題。但是隻是爲了證明我自己的努力在解決它,這是我使用的表結構:
DROP TABLE IF EXISTS `part_no`;
CREATE TABLE IF NOT EXISTS `part_no` (
`#` varchar(5) NOT NULL,
`Part #` varchar(50) DEFAULT NULL,
`Mfr. Part #` varchar(50) DEFAULT NULL,
`Mfr. #` varchar(50) DEFAULT NULL,
`Part Description` varchar(50) DEFAULT NULL,
`Prime Part #` varchar(50) DEFAULT NULL,
`PMA` varchar(50) DEFAULT NULL,
`Key Word` varchar(50) DEFAULT NULL,
`Part Type` varchar(50) DEFAULT NULL,
`Planning Type` varchar(50) DEFAULT NULL,
`Reference Status` varchar(50) DEFAULT NULL,
`Inventory Status` varchar(4) DEFAULT NULL,
PRIMARY KEY (`#`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
你檢查過XML文件的權限嗎?它也適用於MySQL.Please從這裏閱讀 - > http://dev.mysql.com/doc/refman/5.7/en/privileges-provided.html –
@雅虎感謝您的建議,但我我本地開發環境的數據庫的根用戶。我是管理員,我對操作有完全的控制權。 –
你可以發表你的桌子的結構嗎? – wchiquito