Difference between revisions of "Database Module"

From BaseX Documentation
Jump to navigation Jump to search
(Created page with "<p>This module contains methods to list and open databases, explicitly apply available index structures, or get information on the database structure. All functions are introduce...")
 
Line 1: Line 1:
 
<p>This module contains methods to list and open databases, explicitly apply available index structures, or get information on the database structure. All functions are introduced with the <code>db:</code> prefix.</p>  
 
<p>This module contains methods to list and open databases, explicitly apply available index structures, or get information on the database structure. All functions are introduced with the <code>db:</code> prefix.</p>  
==Overview==
 
<p>
 
  <a href="xqdb#attribute-index">attribute-index</a> | <a href="xqdb#fulltext-index">fulltext-index</a> | <a href="xqdb#index-info">index-info</a> | <a href="xqdb#info">info</a> | <a href="xqdb#list">list</a> | <a href="xqdb#open">open</a> | <a href="xqdb#open-id">open-id</a> | <a href="xqdb#open-pre">open-pre</a> | <a href="xqdb#system">system</a> | <a href="xqdb#text-index">text-index</a>
 
</p>
 
 
 
==db:system==  
 
==db:system==  
 
<table>  
 
<table>  

Revision as of 10:56, 6 December 2010

This module contains methods to list and open databases, explicitly apply available index structures, or get information on the database structure. All functions are introduced with the db: prefix.

db:system

     Signatures 
      
       db:system() as xs:string* 
     
     Summary 
Lists information on the database system.
     Rules 
This function returns general information on the database system, such as the database path and current database settings.

db:list

     Signatures 
      
       db:list() as xs:string* 
     
     Summary 
Lists all databases.
     Rules 
This function returns a xs:string sequence with the names of all databases.

db:open

     Signatures 
      
       db:open($name as xs:string) as document-node() 
     
     Summary 
Returns documents from a database.
     Rules 
This function opens the documents of the database specified by $name. The name of the database may be extended by a collection path.
     Examples 
The expression db:open("docs") returns all documents from the database named docs.
The expression db:open("docs/one") returns all documents from the database named docs in the subpath one.
     Errors 
     [BASX0003] is raised if the database is not found.

db:open-pre

     Signatures 
      
       db:open-pre($name as xs:string, $pre as xs:integer) as node() 
     
     Summary 
Returns a specific database node.
     Rules 
This function opens the database specified by $name and returns the node with the pre value specified by $pre.
     Examples 
The expression db:open-pre("docs", 0) returns the first database node from the database named docs.
     Errors 
     [BASX0004] is raised if the specified $pre value does not exist in the database.

db:open-id

     Signatures 
      
       db:open-id($name as xs:string, $id as xs:integer) as node() 
     
     Summary 
Returns a specific database node.
     Rules 
This function opens the database specified by $name and returns the node with the id value specified by $id.
In contrast to the pre value, the id will remain valid after update operations.
     Errors 
     [BASX0004] is raised if the specified $id does not exist in the database.

db:text-index

     Signatures 
      
       db:text-index($string as item()) as text()* 
     
     Summary 
Returns results from a text index request.
     Rules 
This function accesses the text index and returns all text nodes that have $string as string value.
     Errors 
     [BASX0001] is raised if the index is not available.
[BASX0002] is raised if the context item does not represent a database node.

db:attribute-index

     Signatures 
      
       db:attribute-index($string as item()) as attribute()* 
     
db:attribute-index($string as item(), $name as xs:string) as attribute()*
     Summary 
Returns results from a attribute index request.
     Rules 
This function accesses the attribute index and returns all attribute nodes that have $string as string value.
If $name is specified, the resulting attribute nodes are filtered by their attribute name.
     Errors 
     [BASX0001] is raised if the index is not available.
[BASX0002] is raised if the context item does not represent a database node.

db:fulltext-index

     Signatures 
      
       db:fulltext-index($text as xs:string) as text() 
     
     Summary 
Returns results from a full-text index request.
     Rules 
This function accesses the full-text index and returns all text nodes that contain $text.
     Errors 
     [BASX0001] is raised if the index is not available.
[BASX0002] is raised if the context item does not represent a database node.

db:info

     Signatures 
      
       db:info() as xs:string 
     
     Summary 
Returns database information.
     Rules 
This function returns information on the database that is referenced by the current context item.
     Errors 
     [BASX0002] is raised if the context item does not represent a database node.

db:index-info

     Signatures 
      
       db:index-info($type as xs:string) as xs:string 
     
     Summary 
Returns database index information.
     Rules 
This function returns information on an index of the database that is referenced by the current context item.
     $type must be one of the values TEXT, ATTRIBUTE, FULLTEXT, PATH, TAG, or ATTNAME.
     Errors 
     [BASX0001] is raised if the specified index is not available.
[BASX0002] is raised if the context item does not represent a database node.