Difference between revisions of "Commands"

From BaseX Documentation
Jump to navigation Jump to search
Line 11: Line 11:
 
|-
 
|-
 
| valign='top' | '''Summary'''
 
| valign='top' | '''Summary'''
|Adds the files, directory or XML string specified by <code>[input]</code> to the database, using an optional <code>[target]</code> path and an optional file <code>[name]</code>.
+
|Adds the files, directory or XML string specified by <code>[input]</code> to the database, using an optional <code>[target]</code> path and an optional file <code>[name]</code>.<br/>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.
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.
 
 
|}
 
|}
==ALTER==
+
==ALTER DATABASE==
 
{|
 
{|
 
|-
 
|-
 
| valign='top' width='90' | '''Signature'''
 
| valign='top' width='90' | '''Signature'''
|<code>ALTER [USER&#124;DATABASE] [...]</code>
+
|<code>ALTER DATABASE [name] [newname]</code>
 
|-
 
|-
 
| valign='top' | '''Summary'''
 
| valign='top' | '''Summary'''
|Alters the password of a user, or the name of a database:
+
|Alters the <code>[name]</code> of a database to <code>[newname]</code>.
* <code>USER [name] ([password])</code>:
+
|}
: Alters the <code>[password]</code> of the user specified with <code>[name]</code>. If no password is specified in the console mode, it is requested via standard input.
+
==ALTER USER==
* <code>DATABASE [name] [newname]</code>
+
{|
: Alters the <code>[name]</code> of a database to <code>[newname]</code>.
+
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>ALTER USER [name] ([password])</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Alters the <code>[password]</code> of the user specified with <code>[name]</code>. If no password is specified in the console mode, it is requested via standard input.
 
|}
 
|}
 
==BACKUP==
 
==BACKUP==
Line 62: Line 65:
 
|-
 
|-
 
| valign='top' | '''Summary'''
 
| valign='top' | '''Summary'''
|Creates a copy of the database specified by [name].
+
|Creates a copy of the database specified by <code>[name]</code>.
 +
|}
 +
==CREATE DATABASE==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>CREATE DATABASE [name] ([input])</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Creates the database <code>[name]</code> with an optional <code>[input]</code>.<br />The input may either be a single XML document, a directory, a remote URL or a plain XML string.
 +
|}
 +
==CREATE INDEX==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>CREATE INDEX [TEXT&#124;ATTRIBUTE&#124;FULLTEXT&#124;PATH]</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Creates the specified database index.
 
|}
 
|}
==CREATE==
+
==CREATE USER==
 
{|
 
{|
 
|-
 
|-
 
| valign='top' width='90' | '''Signature'''
 
| valign='top' width='90' | '''Signature'''
|<code>CREATE [DATABASE&#124;INDEX&#124;USER] [...]</code>
+
|<code>CREATE USER [name] ([password])</code>:
 
|-
 
|-
 
| valign='top' | '''Summary'''
 
| valign='top' | '''Summary'''
|Creates a new database, index or user:
+
|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.
* <code>DATABASE [name] ([input])</code>:
 
: Creates the database <code>[name]</code> with an optional <code>[input]</code>.
 
: The input may either be a single XML document, a directory, a remote URL or a plain XML string.
 
* <code>INDEX [TEXT&#124;ATTRIBUTE&#124;FULLTEXT&#124;PATH]</code>:
 
: Creates the specified index
 
* <code>USER [name] ([password])</code>:
 
: 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==
 
==CS==
Line 98: Line 112:
 
|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>.
 
|}
 
|}
==DROP==
+
==DROP BACKUP==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>DROP BACKUP [name]</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Drops all backups for the database with the specified <code>[name]</code>.
 +
|}
 +
==DROP DATABASE==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>DROP DATABASE [name]</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Drops the database with the specified <code>[name]</code>.
 +
|}
 +
==DROP INDEX==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>DROP INDEX [PATH&#124;TEXT&#124;ATTRIBUTE&#124;FULLTEXT]</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Drops the specified database index.
 +
|}
 +
==DROP USER==
 
{|
 
{|
 
|-
 
|-
 
| valign='top' width='90' | '''Signature'''
 
| valign='top' width='90' | '''Signature'''
|<code>DROP [DATABASE&#124;INDEX&#124;USER] [...]</code>
+
|<code>DROP USER [name] (ON [database])</code>:
 
|-
 
|-
 
| valign='top' | '''Summary'''
 
| valign='top' | '''Summary'''
|Drops a database, index or user:
+
|Drops the user with the specified <code>[name]</code>. If a <code>[database]</code> is specified, the user is only dropped locally.
* <code>DATABASE [name]</code>:
 
: Drops the database with the specified <code>[name]</code>.
 
* <code>INDEX [PATH&#124;TEXT&#124;ATTRIBUTE&#124;FULLTEXT]</code>:
 
: Drops the specified index.
 
* <code>USER [name] (ON [database])</code>:
 
: Drops the user with the specified <code>[name]</code>. If a <code>[database]</code> is specified, the user is only dropped locally.
 
* <code>BACKUP [name]</code>:
 
: Drops all backups for the database with the specified <code>[name]</code>.
 
 
|}
 
|}
 
==EXIT==
 
==EXIT==
Line 141: Line 174:
 
| valign='top' | '''Summary'''
 
| valign='top' | '''Summary'''
 
|Builds and runs a query for the specified <code>[keywords]</code>. The following modifiers can be used to further limit search:
 
|Builds and runs a query for the specified <code>[keywords]</code>. The following modifiers can be used to further limit search:
:= : looks for exact text nodes
+
<code>= </code> looks for exact text nodes<br/><code>@=</code> looks for exact attributes<br/><code>@ </code> looks for attributes
:@= : looks for exact attributes
 
:@ : looks for attributes
 
 
|}
 
|}
 
==GET==
 
==GET==
Line 176: Line 207:
 
|-
 
|-
 
| valign='top' width='90' | '''Signature'''
 
| valign='top' width='90' | '''Signature'''
|<code>INFO ([DATABASE&#124;INDEX&#124;STORAGE])</code>
+
|<code>INFO</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Shows global information.
 +
|}
 +
==INFO DATABASE==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>INFO DATABASE</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Shows information on the currently opened database.
 +
|}
 +
==INFO INDEX==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>INFO INDEX [name]</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Shows information on the existing index structures. If <code>[name]</code> is specified, information on the specified index is shown.
 +
|}
 +
==INFO STORAGE==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>INFO STORAGE [start end] | [query]</code>
 
|-
 
|-
 
| valign='top' | '''Summary'''
 
| valign='top' | '''Summary'''
|Shows information on the currently opened database:
+
|Shows the internal main table of the currently opened database.
* <code>no argument</code>: Shows global information on the DBMS
 
* <code>DATABASE</code>: Shows general database information
 
* <code>INDEX</code>: Shows information on the existing index structures
 
* <code>STORAGE [start end] | [query]</code>: Shows the main table of the internal storage
 
 
|}
 
|}
 
==KILL==
 
==KILL==
Line 237: Line 291:
 
|-
 
|-
 
| valign='top' | '''Summary'''
 
| valign='top' | '''Summary'''
|Restores a database with the specified [name]. The name may include the timestamp of the backup file.
+
|Restores a database with the specified <code>[name]</code>. The name may include the timestamp of the backup file.
 
|}
 
|}
 
==RUN==
 
==RUN==
Line 257: Line 311:
 
|Sets an <code>[option]</code> to the specified <code>[value]</code>. A list of all options is [[Options|available here]].
 
|Sets an <code>[option]</code> to the specified <code>[value]</code>. A list of all options is [[Options|available here]].
 
|}
 
|}
==SHOW==
+
==SHOW BACKUPS==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>SHOW BACKUPS</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Shows all database backups.
 +
|}
 +
==SHOW DATABASES==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>SHOW DATABASES</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Shows all databases that are opened in the current server instance.
 +
|}
 +
==SHOW SESSIONS==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>SHOW SESSIONS</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Shows all sessions that are connected to the current server instance.
 +
|}
 +
==SHOW USERS==
 
{|
 
{|
 
|-
 
|-
 
| valign='top' width='90' | '''Signature'''
 
| valign='top' width='90' | '''Signature'''
|<code>SHOW [DATABASES&#124;SESSIONS&#124;USERS&#124;BACKUPS]</code>
+
|<code>SHOW USERS (ON [database])</code>
 
|-
 
|-
 
| valign='top' | '''Summary'''
 
| valign='top' | '''Summary'''
|Shows server information:
+
|Shows all users that are registered in the database. If a <code>[database]</code> is specified, local users are shown.
* <code>DATABASES</code>: Shows the currently opened databases.
 
* <code>SESSIONS</code>: Shows the currently active database sessions.
 
* <code>USERS (ON [database])</code>: Shows all known users. If a <code>[database]</code> is specified, local users are shown.
 
* <code>BACKUPS</code>: Shows all database backups.
 
 
|}
 
|}
 
==XQUERY==
 
==XQUERY==

Revision as of 01:49, 6 May 2011

This page lists all commands that are supported by BaseX. Commands can be either run from command line or from the input field in the GUI. Commands, which 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.

ADD

Signature ADD (AS [name]) (TO [target]) [input]
Summary Adds the files, directory or XML string specified by [input] to the 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.

ALTER DATABASE

Signature ALTER DATABASE [name] [newname]
Summary Alters the [name] of a database to [newname].

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:

= looks for exact text nodes
@= looks for exact attributes
@ looks for attributes

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.