Changes

Jump to navigation Jump to search
131 bytes removed ,  20:25, 18 July 2022
no edit summary
* Type in the following command to create and open the database:
<code>
> [[Commands#CREATE DB{{Command|CREATE DB]] }} factbook factbook.xml
</code>
==Execute a Query==
The [[{{Commands#XQUERY|XQUERY]] }} command lets you run a query.
* For example, the following query returns all country nodes in the currently opened factbook database.
<code>
> [[Commands#XQUERY{{Command|XQUERY]] }} //country
</code>
* You can also run queries in files:
<code>
> [[Commands#RUN{{Command|RUN]] }} /Users/John/query.xq
</code>
==Database Commands==
* The following command lists all databases than that can be opened by the currently logged -in user:
<code>
> [[Commands#LIST{{Command|LIST]]}}
</code>
* To open an existing database, execute the following:
<code>
> [[Commands#OPEN{{Command|OPEN]] }} factbook
</code>
* To get information on the currently opened database, type:
<code>
> [[Commands#INFO{{Command|INFO]]}}
</code>
* You can also address a database within your query with the [[{{Function|Database Module#db:open|db:open]] }} function:
<code>
> [[Commands#XQUERY{{Command|XQUERY]] }} db:open("factbook")//country
</code>
* To [[Commands|close]] the current database, please type:
<code>
> [[Commands#CLOSE{{Command|CLOSE]]}}
</code>
* Use the [[Commands#DROP DB|DROP DB]] command to delete a database:
<code>
> [[Commands#DROP DB{{Command|DROP DB]] }} factbook
</code>
<code>
> [[Commands#CREATE DB{{Command|CREATE DB]] }} store
</code><br/>
<code>
> [[Commands#ADD{{Command|ADD]] }} factbook.xml
</code><br/>
<code>
> [[Commands#ADD{{Command|ADD]] }} http://files.basex.org/xml/xmark.xml
</code>
* Deleting a document from a database is easy, but make sure that the database, which contains the addressed document, is currently opened:
<code>
> [[Commands#DELETE{{Command|DELETE]] }} factbook.xml
</code>
==Backup and Restore==
* To backup back up your database, type:
<code>
> [[Commands#CREATE BACKUP{{Command|CREATE BACKUP]] }} factbook
</code>
* To restore your database, type:
<code>
> [[Commands#RESTORE{{Command|RESTORE]] }} factbook
</code>
The backup file is stored in the database directory.It contains the name of the database and a timestamp: <code>[db-name]-[timestamp].zip</code>.If a database is to be restored, and if several backups exist, the backup with the newest timestamp is taken.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu