[Sedna] collection ã使ã£ã¦ã¿ã
Sedna ã¯é«é㪠XMLDBãªã®ã ããã§ï¼ã¤ã³ããã¯ã¹ãã¯ã£ããã§ãã¦ãªãã ã楽ããããªã®ã§ï¼ã¡ãã£ã¨åå¼·ãã¦ã¿ãï¼
ããã£ã¦ãããã¡ã«ï¼è¤æ°ã® XML ããã¥ã¡ã³ãã«ã¾ã¨ã㦠XQuery ããããã®ã¯ã©ããã£ã¦ãããã ãããï¼ã¨æã£ã¦ FAQ ãçºãã¦ããã¨ãã£ã±ããã£ãï¼
Q. I've inserted several documents into my database, each containing XML data almost of the same structure. I want to run an XQuery query against all of those documents. How can I do that? A. If you have a number of documents that have similar structure (the structure must not be exactly the same) and you want to query through the documents, you should store them in a collection. Collections are optimized for querying through documents. How to create and use collection see "Managing Collections" section of the "Sedna Programmer's Guide".
ããããã« collection ã¨ãããæ©è½ã使ãã¾ãããï¼ã¨ãããã¨ãããï¼
å®é¨ãã¦ã¿ãï¼
Sedna ãèµ·åãã
$ se_gov
DB ãä½æ
ããã§ã¯ testdb ã¨ããååã§ä½ãï¼
$ se_cdb testdb
DB ãèµ·å
$ se_sm testdb
(åºæ¬) Sedna ã§ã® XQuery ã®çºè¡æ¹æ³
XQuery ããã¡ã¤ã«ã«æ¸ãã¦
$ se_term -file ãã¡ã¤ã«å DBå
ãããã¯
$ se_term -query ã¯ã¨ãª DBå
以ä¸ã§ã¯å¾è
ã§çºè¡ããï¼
collection "col" ãä½ã
$ se_term -query "CREATE COLLECTION 'col'" testdb
a.xml ããããããã¼ã
$ se_term -query "LOAD 'a.xml' 'a1' 'col'" testdb $ se_term -query "LOAD 'a.xml' 'a2' 'col'" testdb $ se_term -query "LOAD 'a.xml' 'a3' 'col'" testdb $ se_term -query "LOAD 'a.xml' 'a4' 'col'" testdb
collection ã使ã£ã¦ XQuery ãçºè¡ãã¦ã¿ã
for æã使ãããã®ã ããã©ãï¼-query ã§ã©ãæ¸ããï¼ã¨ãããï¼for æã
ä¸è¡ã§ã©ãæ¸ãã®ãç¥ããªãã®ã§ãã¡ã¤ã«ã«ä¿åã㦠-file ã§ããããã¨ã«
ããï¼
(: a.xquery :) for $i in collection('col')//b return <x>{$i}</x>
$ se_term -file a.xquery testdb
çµæ
<x> <b/> </x> <x> <b/> </x> <x> <b/> </x> <x> <b/> </x>
ã¾ã¨ã
XQuery ãæ¸ããã¨èªä½å§ãã¦ã ã£ãã®ã§ï¼ä¾ãããã¼ããã©ï¼ãã£ã¨ä»å¾å½¹
ã«ç«ã¤ã¯ãï¼