Difference between revisions of "Commands"
Jump to navigation
Jump to search
(→CLOSE) |
|||
| Line 23: | Line 23: | ||
|- | |- | ||
| valign='top' | '''Errors''' | | valign='top' | '''Errors''' | ||
| − | |The command fails if one of the documents to be added is not well-formed or | + | |The command fails if no database is opened, if one of the documents to be added is not well-formed, or if it could not be parsed for some other reason. |
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
| Line 45: | Line 45: | ||
|- | |- | ||
| valign='top' | '''Errors''' | | valign='top' | '''Errors''' | ||
| − | |The command fails if one of the specified database names is invalid, if the target database exists | + | |The command fails if one of the specified database names is invalid, if the target database already exists, if the source database does not exist or is currently locked, or if it could not be renamed for some other reason. |
|- | |- | ||
| valign='top' | '''Examples''' | | valign='top' | '''Examples''' | ||
| Line 127: | Line 127: | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
|Creates a copy of the database specified by <code>[name]</code>. | |Creates a copy of the database specified by <code>[name]</code>. | ||
| + | |- | ||
| + | | valign='top' | '''Errors''' | ||
| + | |The command fails if one of the specified database names is invalid, if the target database already exists, if the source database does not exist, or if it could not be renamed for some other reason. | ||
|} | |} | ||
==CREATE DATABASE== | ==CREATE DATABASE== | ||
| Line 141: | Line 144: | ||
|- | |- | ||
| valign='top' | '''Errors''' | | valign='top' | '''Errors''' | ||
| − | |The command fails if one of the documents to be added is not well-formed or | + | |The command fails if the name of the database is invalid, if a database with the same name is currently pinned, or if one of the documents to be added is not well-formed or could not be parsed for some other reason. |
|} | |} | ||
| Line 155: | Line 158: | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
|Creates the specified database index. | |Creates the specified database index. | ||
| + | |- | ||
| + | | valign='top' | '''Errors''' | ||
| + | |The command fails no database is opened, if the specified index is unknown, or if indexing fails for some other reason. | ||
|} | |} | ||
==CREATE USER== | ==CREATE USER== | ||
| Line 167: | Line 173: | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
|Creates a user with the specified <code>[name]</code> and <code>[password]</code>. If no password is specified in the console mode, it is requested via standard input. | |Creates a user with the specified <code>[name]</code> and <code>[password]</code>. If no password is specified in the console mode, it is requested via standard input. | ||
| + | |- | ||
| + | | valign='top' | '''Errors''' | ||
| + | |The command fails if the specified user name is invalid, if the user already exists, or if no password has been specified. | ||
|} | |} | ||
==CS== | ==CS== | ||
| Line 179: | Line 188: | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
|Evaluates the specified <code>[query]</code> and sets the result as new context set. | |Evaluates the specified <code>[query]</code> and sets the result as new context set. | ||
| + | |- | ||
| + | | valign='top' | '''Errors''' | ||
| + | |The command fails if no database is opened, if the specified query is invalid or if it does not return nodes of the currently opened database. | ||
|} | |} | ||
==DELETE== | ==DELETE== | ||
| Line 191: | Line 203: | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
|Deletes all documents from the currently opened database that start with the specified <code>[path]</code>. | |Deletes all documents from the currently opened database that start with the specified <code>[path]</code>. | ||
| + | |- | ||
| + | | valign='top' | '''Errors''' | ||
| + | |The command fails if no database is opened. | ||
|} | |} | ||
==DROP BACKUP== | ==DROP BACKUP== | ||
| Line 202: | Line 217: | ||
|- | |- | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
| − | |Drops all backups | + | |Drops all backups of the database with the specified <code>[name]</code>. |
| + | |- | ||
| + | | valign='top' | '''Errors''' | ||
| + | |The command fails if the specified database name is invalid. | ||
|} | |} | ||
==DROP DATABASE== | ==DROP DATABASE== | ||
| Line 215: | Line 233: | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
|Drops the database with the specified <code>[name]</code>. | |Drops the database with the specified <code>[name]</code>. | ||
| + | |- | ||
| + | | valign='top' | '''Errors''' | ||
| + | |The command fails if the specified database name is invalid, if the database does not exist or is currently locked, or if the database could not be deleted for some other reason. | ||
|} | |} | ||
==DROP INDEX== | ==DROP INDEX== | ||
| Line 227: | Line 248: | ||
| valign='top' | '''Summary''' | | valign='top' | '''Summary''' | ||
|Drops the specified database index. | |Drops the specified database index. | ||
| + | |- | ||
| + | | valign='top' | '''Errors''' | ||
| + | |The command fails if no database is opened, if the specified index is unknown, or if it could not be deleted for some other reason. | ||
|} | |} | ||
==DROP USER== | ==DROP USER== | ||
Revision as of 03:31, 6 May 2011
This page lists all database commands that are supported by BaseX. Database commands can either be 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.
The Permissions indicate which
rights are required by a user to perform a command in the client/server architecture.
A shortcut exists for some of the command keywords. 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]
|
| Permission | WRITE
|
| 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. |
| Errors | The command fails if no database is opened, if one of the documents to be added is not well-formed, or if it could not be parsed for some other reason. |
| Examples |
|
ALTER DATABASE
| Signature | ALTER DATABASE [name] [newname]
|
| Permission | CREATE
|
| Summary | Renames the database specified by [name] to [newname].
|
| Errors | The command fails if one of the specified database names is invalid, if the target database already exists, if the source database does not exist or is currently locked, or if it could not be renamed for some other reason. |
| Examples |
|
ALTER USER
| Signature | ALTER USER [name] ([password])
|
| Permission | ADMIN
|
| Errors | The command fails if the specified user name is invalid, if the user does not exist, or if no password has been specified. |
| Summary | Alters the [password] of the user specified by [name]. If no password is specified in the console mode, it is requested via standard input.
|
BACKUP
| Signature | BACKUP [name]
|
| Permission | CREATE
|
| Summary | Creates a zipped backup of the specified database. The backup file will be suffixed with the current timestamp. |
| Errors | The command fails if the specified database name is invalid, if the database does not exist, or if the database could not be zipped for some other reason. |
CHECK
| Signature | CHECK [input]
|
| Permission | CREATE
|
| Summary | Opens an existing database for the specified [input] or creates a new instance.
|
| Errors | The command fails if the database could beither be opened nor created. |
CLOSE
| Signature | CLOSE
|
| Permission | NONE
|
| Summary | Closes the currently opened database. |
| Errors | The command fails if the database files could not be closed for some unknown reason. |
COPY
| Signature | COPY [name] [newname]
|
| Permission | CREATE
|
| Summary | Creates a copy of the database specified by [name].
|
| Errors | The command fails if one of the specified database names is invalid, if the target database already exists, if the source database does not exist, or if it could not be renamed for some other reason. |
CREATE DATABASE
| Signature | CREATE DATABASE [name] ([input])
|
| Permission | CREATE
|
| 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. |
| Errors | The command fails if the name of the database is invalid, if a database with the same name is currently pinned, or if one of the documents to be added is not well-formed or could not be parsed for some other reason. |
CREATE INDEX
| Signature | CREATE INDEX [TEXT|ATTRIBUTE|FULLTEXT|PATH]
|
| Permission | WRITE
|
| Summary | Creates the specified database index. |
| Errors | The command fails no database is opened, if the specified index is unknown, or if indexing fails for some other reason. |
CREATE USER
| Signature | CREATE USER [name] ([password]):
|
| Permission | ADMIN
|
| 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.
|
| Errors | The command fails if the specified user name is invalid, if the user already exists, or if no password has been specified. |
CS
| Signature | CS [query]
|
| Permission | depends on query |
| Summary | Evaluates the specified [query] and sets the result as new context set.
|
| Errors | The command fails if no database is opened, if the specified query is invalid or if it does not return nodes of the currently opened database. |
DELETE
| Signature | DELETE [path]
|
| Permission | WRITE
|
| Summary | Deletes all documents from the currently opened database that start with the specified [path].
|
| Errors | The command fails if no database is opened. |
DROP BACKUP
| Signature | DROP BACKUP [name]
|
| Permission | CREATE
|
| Summary | Drops all backups of the database with the specified [name].
|
| Errors | The command fails if the specified database name is invalid. |
DROP DATABASE
| Signature | DROP DATABASE [name]
|
| Permission | CREATE
|
| Summary | Drops the database with the specified [name].
|
| Errors | The command fails if the specified database name is invalid, if the database does not exist or is currently locked, or if the database could not be deleted for some other reason. |
DROP INDEX
| Signature | DROP INDEX [PATH|TEXT|ATTRIBUTE|FULLTEXT]
|
| Permission | WRITE
|
| Summary | Drops the specified database index. |
| Errors | The command fails if no database is opened, if the specified index is unknown, or if it could not be deleted for some other reason. |
DROP USER
| Signature | DROP USER [name] (ON [database]):
|
| Permission | ADMIN
|
| Summary | Drops the user with the specified [name]. If a [database] is specified, the user is only dropped locally.
|
EXIT
| Signature | EXIT
|
| Permission | NONE
|
| Summary | Exits the console mode. |
EXPORT
| Signature | EXPORT [path]
|
| Permission | CREATE
|
| Summary | Exports all documents in the database to the specified [path].
|
FIND
| Signature | FIND [keywords]
|
| Permission | READ
|
| Summary | Builds and runs a query for the specified [keywords]. The following modifiers can be used to further limit search:
|
GET
| Signature | GET [option]
|
| Permission | NONE
|
| 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]
|
| Permission | ADMIN
|
| Summary | Grants the specified permission to the specified [user]. If a [database] is specified, the permissions are only granted locally.
|
HELP
| Signature | HELP ([command])
|
| Permission | NONE
|
| Summary | If [command] is specified, information on the specific command is printed; otherwise, all commands are listed.
|
INFO
| Signature | INFO
|
| Permission | READ
|
| Summary | Shows global information. |
INFO DATABASE
| Signature | INFO DATABASE
|
| Permission | READ
|
| Summary | Shows information on the currently opened database. |
INFO INDEX
| Signature | ATTRIBUTE|FULLTEXT|PATH]) |
| Permission | READ
|
| Summary | Shows information on the existing index structures. The output can be optionally limited to the specified index. |
INFO STORAGE
| Signature | [query] |
| Permission | READ
|
| Summary | Shows the internal main table of the currently opened database. |
KILL
| Signature | KILL [name]
|
| Permission | ADMIN
|
| Summary | Kills all sessions of the user specified by [name].
|
LIST
| Signature | LIST ([path])
|
| Permission | NONE
|
| 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]
|
| Permission | READ
|
| 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)
|
| Permission | WRITE
|
| Summary | Optimizes the current database structures. If the ALL flag is specified, the size of all database files is minimized.
|
PASSWORD
| Signature | PASSWORD ([password])
|
| Permission | NONE
|
| 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]
|
| Permission | CREATE
|
| Summary | Restores a database with the specified [name]. The name may include the timestamp of the backup file.
|
RUN
| Signature | RUN [file]
|
| Permission | depends on query |
| Summary | Runs the query contained in [file] and prints the result.
|
SET
| Signature | SET [option] ([value])
|
| Permission | NONE
|
| Summary | Sets an [option] to the specified [value]. A list of all options is available here.
|
SHOW BACKUPS
| Signature | SHOW BACKUPS
|
| Permission | CREATE
|
| Summary | Shows all database backups. |
SHOW DATABASES
| Signature | SHOW DATABASES
|
| Permission | ADMIN
|
| Summary | Shows all databases that are opened in the current server instance. |
SHOW SESSIONS
| Signature | SHOW SESSIONS
|
| Permission | ADMIN
|
| Summary | Shows all sessions that are connected to the current server instance. |
SHOW USERS
| Signature | SHOW USERS (ON [database])
|
| Permission | ADMIN
|
| Summary | Shows all users that are registered in the database. If a [database] is specified, local users are shown.
|
XQUERY
| Signature | XQUERY [query]
|
| Permission | depends on query |
| Summary | Runs the specified [query] and prints the result.
|
| Examples |
|