Changes

Jump to navigation Jump to search
38 bytes removed ,  14:10, 17 January 2011
no edit summary
* To create a database you need an XML document, e.g. [http://www.w3.org/XML/Binary/2005/03/test-data/Over100/factbook.xml factbook.xml].
* Save this document to the directory your working in.
* On the client terminal , run:
<code>
: > create db CREATE DB factbook factbook.xml
</code>
* For example, this query returns all country nodes in the currently opened database.
<code>
: > xquery XQUERY //country
</code>
* You can also run queries in files:
<code>
: > run RUN /Users/John/query.xq
</code>
* Create the new database, named 'xmark'.
<code>
: > create db CREATE DB xmark xmark.xml
</code>
* Set the new database xmark as the context:
<code>
: > open OPEN xmark
</code>
* Now you can easily execute queries on your new database:
<code>
: > xquery XQUERY //people/person/name
</code>
* You can explicitly query the factbook database with the doc()-funtion, no matter what the current context is.
<code>
: > xquery XQUERY doc("factbook")//country
</code>
* Otherwise, to set factbook as the current context, execute the following:
<code>
: > open OPEN factbook
</code>
* To list the current context, type:
<code>
: > show databasesSHOW DATABASES
</code>
* To [[Commands|close]] the current context database type:
<code>
: > closeCLOSE
</code>
* Use the [[Commands|drop]] command to delete the xmark database:
<code>
: > drop db xmarkDROP DBxmark
</code>
===Create a collection=Collection==
'''What is a collection?'''
With BaseX you can group documents into one logical collection. A collection is a database that contains two or more documents. Collections accept any type of XML documents, regardless of their structure.
* First make sure factbook is opened:
<code>
: > open OPEN factbook
</code>
* Now add the xmark.xml document:
<code>
: > add ADD xmark.xml
</code>
===Delete a document from a collection=Document==
* Deleting a document from a collection is very easy:
<code>
: > delete DELETE xmark.xml
</code>
Make sure the collection which contains the xmark.xml document is opened.
===Delete a collection=Collection==
Deleting a collection is the same as deleting a database.
* To delete the collection factbook, type:
<code>
: > drop DROP factbook
</code>
===Get information about the server=Server Information==
Several commands help to explore the state of a server. For a complete list visit the [[Commands|commands section]].
* To see all databases on the server, type:
<code>
: > listLIST
</code>
* To see which database is currently opened:
<code>
: > show databasesSHOW DATABASES
</code>
* To see the general information of the opened database, type:
<code>
: > infoINFO
</code>
* To see the users in BaseX, type:
<code>
: > show usersSHOW USERS
</code>
===Backup and Restore===
To backup your database, type:
:<code>
> backup BACKUP factbook
</code>
To restore your database, type:
:<code>
> restore RESTORE factbook
</code>
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu