List:Commits« Previous MessageNext Message »
From:jon Date:July 13 2007 3:44pm
Subject:svn commit - mysqldoc@docsrva: r7113 - trunk/refman-5.2
View as plain text  
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>&lt;</literal> and <literal>&gt;</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&gt; <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>
+&lt;?xml version="1.0"?&gt;
+&lt;list&gt;
+  &lt;person person_id="1" fname="Pekka" lname="Nousiainen"/&gt;
+  &lt;person person_id="2" fname="Jonas" lname="Oreland"/&gt;
+  &lt;person person_id="3"&gt;&lt;fname&gt;Mikael&lt;/fname&gt;&lt;lname&gt;Ronström&lt;/lname&gt;&lt;/person&gt;
+  &lt;person person_id="4"&gt;&lt;fname&gt;Lars&lt;/fname&gt;&lt;lname&gt;Thalmann&lt;/lname&gt;&lt;/person&gt;
+  &lt;person&gt;&lt;field name="person_id"&gt;5&lt;/field&gt;&lt;field name="fname"&gt;Tomas&lt;/field&gt;&lt;field name="lname"&gt;Ulin&lt;/field&gt;&lt;/person&gt;
+  &lt;person&gt;&lt;field name="person_id"&gt;6&lt;/field&gt;&lt;field name="fname"&gt;Martin&lt;/field&gt;&lt;field name="lname"&gt;Sköld&lt;/field&gt;&lt;/person&gt;
+&lt;/list&gt;
+</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&gt; <userinput>LOAD XML LOCAL INFILE 'person.xml'</userinput>
+    -&gt;   <userinput>INTO TABLE person</userinput>
+    -&gt;   <userinput>ROWS IDENTIFIED BY '&lt;person&gt;';</userinput>
+
+Query OK, 6 rows affected (0.00 sec)


Thread
svn commit - mysqldoc@docsrva: r7113 - trunk/refman-5.2jon13 Jul