mysql에서 xml에 지원하는 두 함수extractvalue 업데이트xml
5862 단어 데이터베이스
mysql> create table x(
-> doc varchar(150)
-> );
Query OK, 0 rows affected (0.08 sec)
mysql> insert into x values('
'>
'> </span>A guide to the SQL standard<span class="hljs-xmlDocTag"/></span>
<span class="hljs-comment">'> <span class="hljs-xmlDocTag"><author/></span></span>
<span class="hljs-comment">'> <span class="hljs-xmlDocTag"><initial/></span>CJ<span class="hljs-xmlDocTag"/></span>
<span class="hljs-comment">'> <span class="hljs-xmlDocTag"><surname/></span>Date<span class="hljs-xmlDocTag"/></span>
<span class="hljs-comment">'> <span class="hljs-xmlDocTag"/></span>
<span class="hljs-comment">'> <span class="hljs-xmlDocTag"/></span>
<span class="hljs-comment">'> ');</span>
Query OK, <span class="hljs-number">1</span> row affected (<span class="hljs-number">0.10</span> sec)
mysql> insert <span class="hljs-keyword">into</span> x values(<span class="hljs-comment">'</span>
<span class="hljs-comment">'> <span class="hljs-xmlDocTag"><book/></span></span>
<span class="hljs-comment">'> <span class="hljs-xmlDocTag"><title/></span>SQL:1999<span class="hljs-xmlDocTag"/></span>
<span class="hljs-comment">'> <span class="hljs-xmlDocTag"><author/></span></span>
<span class="hljs-comment">'> <span class="hljs-xmlDocTag"><initial/></span>J<span class="hljs-xmlDocTag"/></span>
<span class="hljs-comment">'> <span class="hljs-xmlDocTag"><surname/></span>Melton<span class="hljs-xmlDocTag"/></span>
<span class="hljs-comment">'> <span class="hljs-xmlDocTag"/></span>
<span class="hljs-comment">'> <span class="hljs-xmlDocTag"/></span>
<span class="hljs-comment">'> ');</span>
Query OK, <span class="hljs-number">1</span> row affected (<span class="hljs-number">0.08</span> sec)
</code></pre>
<p>EXTRACTVALUE (XML_document, XPath_string); <br/> :XML_document String , XML , Doc <br/> :XPath_string (Xpath ). <br/> : XML </p>
<pre><code><span class="hljs-header">mysql> select extractvalue(doc,'/book/author/initial') from x;
+------------------------------------------+</span>
<span class="hljs-header">| extractvalue(doc,'/book/author/initial') |
+------------------------------------------+</span>
| CJ |
<span class="hljs-header">| J |
+------------------------------------------+</span>
2 rows in set (0.00 sec)
<span class="hljs-header">mysql> select extractvalue(doc,'/*/*/initial') from x;
+----------------------------------+</span>
<span class="hljs-header">| extractvalue(doc,'/*/*/initial') |
+----------------------------------+</span>
| CJ |
<span class="hljs-header">| J |
+----------------------------------+</span>
2 rows in set (0.00 sec)</code></pre>
<p>updatexml()</p>
<p>UPDATEXML (XML_document, XPath_string, new_value); <br/> :XML_document String , XML , Doc <br/> :XPath_string (Xpath ) , Xpath , 。 <br/> :new_value,String , <br/> : </p>
<pre><code>mysql> update x set doc=updatexml(doc,<span class="hljs-emphasis">'/book/author/initial'</span>,<span class="hljs-emphasis">'!!!'</span>);
Query OK, 2 rows affected (0.08 sec)
Rows matched: 2 Changed: 2 Warnings: 0
<span class="hljs-header">mysql> select * from x;
+------------------------------------------------------------------------</span>
-----------------------------+
| doc
<span class="hljs-header"> |
+------------------------------------------------------------------------</span>
-----------------------------+
|
<book>
<title>A guide to the SQL standard
!!!
Date
|
|
SQL:1999
!!!
Melton
|
+------------------------------------------------------------------------
-----------------------------+
2 rows in set (0.00 sec)
link:http://www.blogjava.net/chenpengyi/archive/2006/07/11/57578.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
SQLite의 query로 망설임이것은 내가 처음 안드로이드 응용 프로그램 개발에서 망설이고, 그 후 해결 된 방법을 비망록으로 철자하고 있습니다. java에서 SQLite를 이용한 애플리케이션을 작성하는 동안 EditText에 입력된 item이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.