Author: jstephens
Date: 2007-07-13 17:44:32 +0200 (Fri, 13 Jul 2007)
New Revision: 7113
Log:
More LOAD XML stuff...
Removed:
0 Skipped: 0 Warnings: 0
0 Skipped: 0 Warnings: 0
Modified:
trunk/refman-5.2/sql-syntax.xml
Modified: trunk/refman-5.2/sql-syntax.xml
===================================================================
--- trunk/refman-5.2/sql-syntax.xml 2007-07-13 14:29:50 UTC (rev 7112)
+++ trunk/refman-5.2/sql-syntax.xml 2007-07-13 15:44:32 UTC (rev 7113)
Changed blocks: 5, Lines Added: 66, Lines Deleted: 17; 5071 bytes
@@ -8139,10 +8139,10 @@
<section id="load-xml">
- <title><literal>LOAD XML INFILE</literal> Syntax</title>
+ <title><literal>LOAD XML</literal> Syntax</title>
<indexterm>
- <primary>LOAD XML INFILE</primary>
+ <primary>LOAD XML</primary>
</indexterm>
<remark role="help-topic" condition="LOAD XML"/>
@@ -8170,21 +8170,21 @@
<remark role="help-description-begin"/>
<para>
- The <literal>LOAD XML INFILE</literal> statement reads data from
- an XML file into a table. The
- <replaceable>filename</replaceable> must be given as a literal
- string. The <replaceable>tagname</replaceable> in the optional
- <literal>ROWS IDENTIFIED BY</literal> clause must also be given
- as a literal string, and must be surrounded by angle brackets
+ The <literal>LOAD XML</literal> statement reads data from an XML
+ file into a table. The <replaceable>filename</replaceable> must
+ be given as a literal string. The
+ <replaceable>tagname</replaceable> in the optional <literal>ROWS
+ IDENTIFIED BY</literal> clause must also be given as a literal
+ string, and must be surrounded by angle brackets
(<literal><</literal> and <literal>></literal>).
</para>
<para>
- <literal>LOAD XML INFILE</literal> acts as the complement of
- running the <command>mysql</command> client in XML output mode
- (that is, starting the client with the <option>--xml</option>
- option). To write data from a table to an XML file, use a
- command such as the following one from the system shell:
+ <literal>LOAD XML</literal> acts as the complement of running
+ the <command>mysql</command> client in XML output mode (that is,
+ starting the client with the <option>--xml</option> option). To
+ write data from a table to an XML file, use a command such as
+ the following one from the system shell:
<programlisting>
shell> <userinput>mysql --xml -e 'SELECT * FROM mytable' > file.xml</userinput>
@@ -8255,8 +8255,8 @@
<para>
The following clauses work essenitally the same way for
- <literal>LOAD XML INFILE</literal> as they do for <literal>LOAD
- DATA INFILE</literal>:
+ <literal>LOAD XML</literal> as they do for <literal>LOAD
+ DATA</literal>:
<itemizedlist>
@@ -8308,8 +8308,8 @@
LINES</literal> or <literal>IGNORE
<replaceable>number</replaceable> ROWS</literal> clause causes
the first <replaceable>number</replaceable> rows in the XML file
- to be skipped. It is analogous to the <literal>LOAD DATA
- INFILE</literal> statement's <literal>IGNORE ... LINES</literal>
+ to be skipped. It is analogous to the <literal>LOAD
+ DATA</literal> statement's <literal>IGNORE ... LINES</literal>
clause.
</para>
@@ -8324,6 +8324,197 @@
http://lists.mysql.com/internals/34170
</remark>
+ <para>
+ To illustrate how this statement is used, suppose that we have a
+ table created as follows:
+
+<programlisting>
+USE test;
+
+CREATE TABLE person (
+ person_id INT NOT NULL PRIMARY KEY,
+ fname VARCHAR(40) NULL,
+ lname VARCHAR(40) NULL,
+ created TIMESTAMP
+);
+</programlisting>
+
+ Suppose further that this table is initially empty.
+ </para>
+
+ <para>
+ Now suppose we have a simple XML file
+ <filename>person.xml</filename>, whose contents are as shown
+ here:
+
+<programlisting>
+<?xml version="1.0"?>
+<list>
+ <person person_id="1" fname="Pekka" lname="Nousiainen"/>
+ <person person_id="2" fname="Jonas" lname="Oreland"/>
+ <person person_id="3"><fname>Mikael</fname><lname>Ronström</lname></person>
+ <person person_id="4"><fname>Lars</fname><lname>Thalmann</lname></person>
+ <person><field name="person_id">5</field><field name="fname">Tomas</field><field name="lname">Ulin</field></person>
+ <person><field name="person_id">6</field><field name="fname">Martin</field><field name="lname">Sköld</field></person>
+</list>
+</programlisting>
+
+ Each of the allowable XML formats discussed previously is
+ represented in this example file.
+ </para>
+
+ <para>
+ To import the data in <filename>person.xml</filename> into the
+ <literal>person</literal> table, you can use this statement:
+
+<programlisting>
+mysql> <userinput>LOAD XML LOCAL INFILE 'person.xml'</userinput>
+ -> <userinput>INTO TABLE person</userinput>
+ -> <userinput>ROWS IDENTIFIED BY '<person>';</userinput>
+
+Query OK, 6 rows affected (0.00 sec)
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r7113 - trunk/refman-5.2 | jon | 13 Jul |