Commands
Jump to navigation
Jump to search
This page lists all database commands that are supported by BaseX. Database commands can be either run from the Command Line, the Language Bindings, JAX-RX, the input field in the GUI, or in many other ways.
If the GUI is used, all commands that are triggered by the GUI itself will show up in the Info View.
A short version exists for some command arguments. For example, you may replace the DATABASE keyword with DB.
Contents
- 1 ADD
- 2 ALTER DATABASE
- 3 ALTER USER
- 4 BACKUP
- 5 CHECK
- 6 CLOSE
- 7 COPY
- 8 CREATE DATABASE
- 9 CREATE INDEX
- 10 CREATE USER
- 11 CS
- 12 DELETE
- 13 DROP BACKUP
- 14 DROP DATABASE
- 15 DROP INDEX
- 16 DROP USER
- 17 EXIT
- 18 EXPORT
- 19 FIND
- 20 GET
- 21 GRANT
- 22 HELP
- 23 INFO
- 24 INFO DATABASE
- 25 INFO INDEX
- 26 INFO STORAGE
- 27 KILL
- 28 LIST
- 29 OPEN
- 30 OPTIMIZE
- 31 PASSWORD
- 32 RESTORE
- 33 RUN
- 34 SET
- 35 SHOW BACKUPS
- 36 SHOW DATABASES
- 37 SHOW SESSIONS
- 38 SHOW USERS
- 39 XQUERY
ADD
| Signature | ADD (AS [name]) (TO [target]) [input]
|
| Summary | Adds the files, directory or XML string specified by [input] to the currently opened database, using an optional [target] path and an optional file [name].The input may either be a single XML document, a directory, a remote URL or a plain XML string. The optional name is ignored if the input is a directory. |
| Examples |
|
ALTER DATABASE
| Signature | ALTER DATABASE [name] [newname]
|
| Summary | Alters the [name] of a database to [newname].
|
| Examples |
|
ALTER USER
| Signature | ALTER USER [name] ([password])
|
| Summary | Alters the [password] of the user specified with [name]. If no password is specified in the console mode, it is requested via standard input.
|
BACKUP
| Signature | BACKUP [name]
|
| Summary | Creates a zipped backup of the specified database. The backup file will be suffixed with the current timestamp. |
CHECK
| Signature | CHECK [input]
|
| Summary | Opens an existing database for the specified [input] or creates a new instance.
|
CLOSE
| Signature | CLOSE
|
| Summary | Closes the currently opened database. |
COPY
| Signature | COPY [name] [newname]
|
| Summary | Creates a copy of the database specified by [name].
|
CREATE DATABASE
| Signature | CREATE DATABASE [name] ([input])
|
| Summary | Creates the database [name] with an optional [input].The input may either be a single XML document, a directory, a remote URL or a plain XML string. |
CREATE INDEX
| Signature | CREATE INDEX [TEXT|ATTRIBUTE|FULLTEXT|PATH]
|
| Summary | Creates the specified database index. |
CREATE USER
| Signature | CREATE USER [name] ([password]):
|
| Summary | Creates a user with the specified [name] and [password]. If no password is specified in the console mode, it is requested via standard input.
|
CS
| Signature | CS [query]
|
| Summary | Evaluates the specified [query] and sets the result as new context set.
|
DELETE
| Signature | DELETE [path]
|
| Summary | Deletes all documents from the currently opened database that start with the specified [path].
|
DROP BACKUP
| Signature | DROP BACKUP [name]
|
| Summary | Drops all backups for the database with the specified [name].
|
DROP DATABASE
| Signature | DROP DATABASE [name]
|
| Summary | Drops the database with the specified [name].
|
DROP INDEX
| Signature | DROP INDEX [PATH|TEXT|ATTRIBUTE|FULLTEXT]
|
| Summary | Drops the specified database index. |
DROP USER
| Signature | DROP USER [name] (ON [database]):
|
| Summary | Drops the user with the specified [name]. If a [database] is specified, the user is only dropped locally.
|
EXIT
| Signature | EXIT
|
| Summary | Exits the console mode. |
EXPORT
| Signature | EXPORT [path]
|
| Summary | Exports all documents in the database to the specified [path].
|
FIND
| Signature | FIND [keywords]
|
| Summary | Builds and runs a query for the specified [keywords]. The following modifiers can be used to further limit search:
|
GET
| Signature | GET [option]
|
| Summary | Returns the value of the specified [option]. A list of all options is available here.
|
GRANT
| Signature | GRANT [NONE|READ|WRITE|CREATE|ADMIN] (ON [database]) TO [user]
|
| Summary | Grants the specified permission to the specified [user]. If a [database] is specified, the permissions are only granted locally.
|
HELP
| Signature | HELP ([command])
|
| Summary | If [command] is specified, information on the specific command is printed; otherwise, all commands are listed.
|
INFO
| Signature | INFO
|
| Summary | Shows global information. |
INFO DATABASE
| Signature | INFO DATABASE
|
| Summary | Shows information on the currently opened database. |
INFO INDEX
| Signature | INFO INDEX [name]
|
| Summary | Shows information on the existing index structures. If [name] is specified, information on the specified index is shown.
|
INFO STORAGE
| Signature | [query] |
| Summary | Shows the internal main table of the currently opened database. |
KILL
| Signature | KILL [name]
|
| Summary | Kills all sessions of the user specified by [name].
|
LIST
| Signature | LIST ([path])
|
| Summary | Lists all available databases, or the documents in a database. [path] is the name of the database, optionally followed by a path to the requested documents.
|
OPEN
| Signature | OPEN [path]
|
| Summary | Opens the documents in a database. [path] is the name of the database, optionally followed by a path to the requested documents.
|
OPTIMIZE
| Signature | OPTIMIZE (ALL)
|
| Summary | Optimizes the current database structures. If the ALL flag is specified, the size of all database files is minimized.
|
PASSWORD
| Signature | PASSWORD ([password])
|
| Summary | Changes the [password] of the current user. If no password is specified in the console mode, it is requested via standard input.
|
RESTORE
| Signature | RESTORE [name]
|
| Summary | Restores a database with the specified [name]. The name may include the timestamp of the backup file.
|
RUN
| Signature | RUN [path]
|
| Summary | Runs the query file specified by [path] and prints the result.
|
SET
| Signature | SET [option] ([value])
|
| Summary | Sets an [option] to the specified [value]. A list of all options is available here.
|
SHOW BACKUPS
| Signature | SHOW BACKUPS
|
| Summary | Shows all database backups. |
SHOW DATABASES
| Signature | SHOW DATABASES
|
| Summary | Shows all databases that are opened in the current server instance. |
SHOW SESSIONS
| Signature | SHOW SESSIONS
|
| Summary | Shows all sessions that are connected to the current server instance. |
SHOW USERS
| Signature | SHOW USERS (ON [database])
|
| Summary | Shows all users that are registered in the database. If a [database] is specified, local users are shown.
|
XQUERY
| Signature | XQUERY [query]
|
| Summary | Runs the specified [query] and prints the result.
|
| Examples |
|