Commands

This article is part of the Getting Started Section. It lists all database commands supported by BaseX.

Commands can be executed from the Command Line, as part of Scripts, via the Clients, REST, the input field in the GUI, and other ways. If the GUI is used, all commands that are triggered by the GUI itself will show up in the Info View. The Permission fields indicate which rights are required by a user to perform a command in the client/server architecture.

=Basics=

Command Scripts
On command line, multiple commands can be written down in a single line (separated by semicolons). You can also put them into a command script: Database commands in both string and XML syntax can be placed in a text file and stored as file with the BaseX command script suffix .bxs. If the path to a script file is passed on to BaseX on command-line, or if it is opened in the GUI editor, it will be recognized and evaluated as such.

String Syntax
Lines starting with  are interpreted as comments and are skipped. With the following script, a database is created, two documents are added to it, and a query is performed:

 CREATE DB test ADD TO embedded.xml embedded XQUERY { count(//text) } CLOSE
 * 1) run query

XML Syntax
The string syntax is limited when XML snippets need to be embedded in a command, or when complex queries are to be specified.

The XML syntax provides more flexibility here. Multiple commands can be enclosed by a root element. Some commands, such as, allow you to directly embed XML documents. If you want to embed XML in XQuery expressions, entities should be encoded, or the CDATA syntax should be used:

   embedded <![CDATA[ { count(//text) } ]]>

Glob Syntax
Some commands support the glob syntax to address more than one database or user. Question marks and asterisks can be used to match one or more characters, and commas can be used to separate multiple patterns. Some examples:


 * AB? addresses all names with the characters AB and one more character.
 * *AB addresses all names ending with the characters AB.
 * X*,Y*,Z* addresses all names starting with the characters X, Y, or Z.

Valid Names
Database and user names follow the same naming constraints: Names are restricted to ASCII characters. They must at least have one character, and they may contain letters, numbers and any of the special characters. The following characters are reserved for other features:


 * : glob syntax
 * : Separator for multiple database commands on the command line
 * : Directory path separators
 * : invalid filename characters on Windows
 * Names starting or ending with : hidden folders (e.g. the .logs directory)

Aliases
In all commands, the DB keyword can be replaced by DATABASE.

=Database Operations=

CREATE INDEX
Token index added.

COPY
=Administration=

INFO STORAGE
= Querying =

REPO DELETE
=Updates=

FLUSH
=Monitoring=

JOBS STOP
=User Management=

PASSWORD
=General Commands=

QUIT
=Changelog=


 * Version 9.3
 * Added:


 * Version 8.6
 * Updated: : If called by non-admins, will only return the current user


 * Version 8.5
 * Added:, ,
 * Updated: Valid Names: allow dots (except as first and last character)


 * Version 8.4
 * Updated:, , : token index added
 * Updated: : Query argument removed, start/end added to XML syntax.
 * Updated: : Token index added; index TAG renamed to ELEMNAME; index ATTNAME renamed to ATTRNAME
 * Updated: : adopt original index options


 * Version 8.2
 * Removed: CREATE EVENT, DROP EVENT and SHOW EVENTS command


 * Version 8.0
 * Updated: commands for User Management
 * Updated: : path argument added
 * Removed: CS command
 * Added:


 * Version 7.9
 * Added: runs XQUnit tests.


 * Version 7.7
 * Updated: syntax of valid names.


 * Version 7.5
 * Added: executes a command script.
 * Added: performs integrity checks.
 * Added: automatic detection of Command Scripts.
 * Removed: SHOW DATABASES; information is also returned by.
 * Removed: : path argument.


 * Version 7.3
 * Added: XML Syntax added.
 * Updated: can now be used to create empty databases.
 * Updated: Names and paths in and  are now specified as separate arguments.


 * Version 7.2.1
 * Updated: permissions for and  changed from READ to NONE.


 * Version 7.2
 * Updated:, (PATH argument removed. Path summary is always available now and updated with ).
 * Updated: permissions for, and.


 * Version 7.1
 * Updated: (killing sessions by specifying IP:port)


 * Version 7.0
 * Added:, ,.
 * Updated: : simplified arguments.