Changes

Jump to navigation Jump to search
106 bytes removed ,  16:19, 25 July 2022
no edit summary
This page is part of the [[Getting Started]] Section.It introduces you to the standalone command-line mode of BaseX.
=Startup=
* If you have installed BaseX on ''Windows'', click on the '''BaseX Standalone''' icon.
All operations will be performed with admin permissions (no password needs to be supplied). Various [[Command-Line_Options#Standalone|command-line options]] are available to simplify batch processing. The [[Start_Scripts|start script]] can be adjusted for individual purposes (e.g. if the default memory limit is too restrictive).
Please note that the The standalone client must not be used if you perform parallel (concurrent) read and write operations on your databases. See [[Startup#Concurrent Operations|Concurrent Operations]] for more details.
=Operations=
==Create a Database==
* To create a database , you need an XML document, e.g. , [https://files.basex.org/xml/factbook.xml factbook.xml].* Save this document to your working directory.* Type and type in the following command to create and open the database:
<code>
> {{Command|CREATE DB}} factbook factbook.xml
: '''factbook.xml''' is the initial input of the database<br/>
; Where is By default, databases are stored in the database stored?<code>basex/data</code> directory of your project’s home directory. Depending on your [[Configuration]], the location may vary.
By default, databases are stored in the <code>basex/data</code> directory, which is located in your home folder.Depending on your [[Configuration]], the location of your home folder varies. For example, on ==Execute a Mac it's <code>/Users/John</code>, if your name is John.Query==
==Execute The {{Commands|XQUERY}} command lets you run a Query==query. The following query returns all country elements of the currently opened database:
The {{Commands|XQUERY}} command lets you run a query.
* For example, the following query returns all country nodes in the currently opened factbook database.
<code>
> {{Command|XQUERY}} //country
</code>
* You can also run queries in files: 
<code>
> {{Command|RUN}} /Userspath/Johnto/query.xq
</code>
==Database Commands==
* The following command lists all databases that can be opened by the currently logged-in user: 
<code>
> {{Command|LIST}}
</code>
* To open an existing database, execute the following: 
<code>
> {{Command|OPEN}} factbook
</code>
* To get information on the currently opened database, type: 
<code>
> {{Command|INFO}}
</code>
* You can also address a database within your query with the {{Function|Database|db:get}} function: 
<code>
> {{Command|XQUERY}} db:get("factbook")//country
</code>
* To close the current database, please type:  
<code>
> {{Command|CLOSE}}
</code>
* Use the {{CommandsCommand|DROP DB}} command to delete a database: 
<code>
> {{Command|DROP DB}} factbook
</code>
* Deleting a document from a database is easy, but make sure that the database, which contains the addressed document, is currently opened: 
<code>
> {{Command|DELETE}} factbook.xml
==Backup and Restore==
* To back up and restore your database, type: 
<code>
> {{Command|CREATE BACKUP}} factbook
</code> * To restore your database, type:<br/>
<code>
> {{Command|RESTORE}} factbook
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu