Difference between revisions of "Commands"

From BaseX Documentation
Jump to navigation Jump to search
Line 4: Line 4:
 
A short version exists for some command arguments. For example, you may replace the <code>DATABASE</code> keyword with <code>DB</code>.
 
A short version exists for some command arguments. For example, you may replace the <code>DATABASE</code> keyword with <code>DB</code>.
  
<hr/>
 
<div style="float:left; width:48%;">
 
 
==ADD==
 
==ADD==
 
{|
 
{|
Line 17: Line 15:
 
The optional name is ignored if the input is a directory.
 
The optional name is ignored if the input is a directory.
 
|}
 
|}
 
+
==ALTER==
===ALTER===
+
{|
 
+
|-
'''<code>ALTER [USER|DATABASE] [...]</code>'''
+
| valign='top' width='90' | '''Signature'''
 
+
|<code>ALTER [USER&#124;DATABASE] [...]</code>
Alters the password of a user, or the name of a database:
+
|-
 +
| valign='top' | '''Summary'''
 +
|Alters the password of a user, or the name of a database:
 
* <code>USER [name] ([password])</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.
 
: 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.
 
* <code>DATABASE [name] [newname]</code>
 
* <code>DATABASE [name] [newname]</code>
 
: Alters the <code>[name]</code> of a database to <code>[newname]</code>.
 
: Alters the <code>[name]</code> of a database to <code>[newname]</code>.
<hr/>
+
|}
===BACKUP===
+
==BACKUP==
 
+
{|
'''<code>BACKUP [name]</code>'''
+
|-
 
+
| valign='top' width='90' | '''Signature'''
Creates a zipped backup of the specified database. The backup file will be suffixed with the current timestamp.
+
|<code>BACKUP [name]</code>
<hr/>
+
|-
===CHECK===
+
| valign='top' | '''Summary'''
 
+
|Creates a zipped backup of the specified database. The backup file will be suffixed with the current timestamp.
'''<code>CHECK [input]</code>'''
+
|}
 
+
==CHECK==
Opens an existing database for the specified <code>[input]</code> or creates a new instance.
+
{|
<hr/>
+
|-
===CLOSE===
+
| valign='top' width='90' | '''Signature'''
 
+
|<code>CHECK [input]</code>
'''<code>CLOSE </code>'''
+
|-
 
+
| valign='top' | '''Summary'''
Closes the currently opened database.
+
|Opens an existing database for the specified <code>[input]</code> or creates a new instance.
<hr/>
+
|}
===COPY===
+
==CLOSE==
 
+
{|
'''<code>COPY [name] [newname]</code>'''
+
|-
 
+
| valign='top' width='90' | '''Signature'''
Creates an identical copy of the specified database.
+
|<code>CLOSE </code>
<hr/>
+
|-
===CREATE===
+
| valign='top' | '''Summary'''
 
+
|Closes the currently opened database.
'''<code>CREATE [DATABASE|INDEX|USER] [...]</code>'''
+
|}
 
+
==COPY==
Creates a new database, index or user:
+
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>COPY [name] [newname]</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Creates a copy of the database specified by [name].
 +
|}
 +
==CREATE==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>CREATE [DATABASE&#124;INDEX&#124;USER] [...]</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Creates a new database, index or user:
 
* <code>DATABASE [name] ([input])</code>:
 
* <code>DATABASE [name] ([input])</code>:
 
: Creates the database <code>[name]</code> with an optional <code>[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.
 
: The input may either be a single XML document, a directory, a remote URL or a plain XML string.
* <code>INDEX [TEXT|ATTRIBUTE|FULLTEXT|PATH]</code>:
+
* <code>INDEX [TEXT&#124;ATTRIBUTE&#124;FULLTEXT&#124;PATH]</code>:
 
: Creates the specified index
 
: Creates the specified index
 
* <code>USER [name] ([password])</code>:
 
* <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.
 
: Creates a user with the specified [name] and [password]. If no password is specified in the console mode, it is requested via standard input.
<hr/>
+
|}
===CS===
+
==CS==
 
+
{|
'''<code>CS [query]</code>'''
+
|-
 
+
| valign='top' width='90' | '''Signature'''
Evaluates the specified <code>[query]</code> and sets the result as new context set.
+
|<code>CS [query]</code>
<hr/>
+
|-
===DELETE===
+
| valign='top' | '''Summary'''
 
+
|Evaluates the specified <code>[query]</code> and sets the result as new context set.
'''<code>DELETE [path]</code>'''
+
|}
 
+
==DELETE==
Deletes all documents from the currently opened database that start with the specified <code>[path]</code>.
+
{|
<hr/>
+
|-
===DROP===
+
| valign='top' width='90' | '''Signature'''
 
+
|<code>DELETE [path]</code>
'''<code>DROP [DATABASE|INDEX|USER] [...]</code>'''
+
|-
 
+
| valign='top' | '''Summary'''
Drops a database, index or user:
+
|Deletes all documents from the currently opened database that start with the specified <code>[path]</code>.
 +
|}
 +
==DROP==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>DROP [DATABASE&#124;INDEX&#124;USER] [...]</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Drops a database, index or user:
 
* <code>DATABASE [name]</code>:
 
* <code>DATABASE [name]</code>:
 
: Drops the database with the specified <code>[name]</code>.
 
: Drops the database with the specified <code>[name]</code>.
* <code>INDEX [PATH|TEXT|ATTRIBUTE|FULLTEXT]</code>:
+
* <code>INDEX [PATH&#124;TEXT&#124;ATTRIBUTE&#124;FULLTEXT]</code>:
 
: Drops the specified index.
 
: Drops the specified index.
 
* <code>USER [name] (ON [database])</code>:
 
* <code>USER [name] (ON [database])</code>:
Line 90: Line 114:
 
* <code>BACKUP [name]</code>:
 
* <code>BACKUP [name]</code>:
 
: Drops all backups for the database with the specified <code>[name]</code>.
 
: Drops all backups for the database with the specified <code>[name]</code>.
<hr/>
+
|}
===EXIT===
+
==EXIT==
 
+
{|
'''<code>EXIT </code>'''
+
|-
 
+
| valign='top' width='90' | '''Signature'''
Exits the console mode.
+
|<code>EXIT </code>
<hr/>
+
|-
===EXPORT===
+
| valign='top' | '''Summary'''
 
+
|Exits the console mode.
'''<code>EXPORT [path]</code>'''
+
|}
 
+
==EXPORT==
Exports all documents in the database to the specified <code>[path]</code>.
+
{|
 
+
|-
</div><div style="float:left; width:4%;">&nbsp;
+
| valign='top' width='90' | '''Signature'''
</div><div style="float:left; width:48%;">
+
|<code>EXPORT [path]</code>
===FIND===
+
|-
 
+
| valign='top' | '''Summary'''
'''<code>FIND [keywords]</code>'''
+
|Exports all documents in the database to the specified <code>[path]</code>.
 
+
|}
Builds and runs a query for the specified <code>[keywords]</code>. The following modifiers can be used to further limit search:
+
==FIND==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>FIND [keywords]</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|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
 
:=  : looks for exact text nodes
 
:@= : looks for exact attributes
 
:@= : looks for exact attributes
 
:@  : looks for attributes
 
:@  : looks for attributes
<hr/>
+
|}
===GET===
+
==GET==
 
+
{|
'''<code>GET [option]</code>'''
+
|-
 
+
| valign='top' width='90' | '''Signature'''
Returns the value of the specified <code>[option]</code>. A list of all options is [[Options|available here]].
+
|<code>GET [option]</code>
<hr/>
+
|-
===GRANT===
+
| valign='top' | '''Summary'''
 
+
|Returns the value of the specified <code>[option]</code>. A list of all options is [[Options|available here]].
'''<code>GRANT [NONE|READ|WRITE|CREATE|ADMIN] (ON [database]) TO [user]</code>'''
+
|}
 
+
==GRANT==
Grants the specified [[User_Management#Permissions|permission]] to the specified <code>[user]</code>. If a <code>[database]</code> is specified, the permissions are only granted locally.
+
{|
<hr/>
+
|-
===HELP===
+
| valign='top' width='90' | '''Signature'''
 
+
|<code>GRANT [NONE&#124;READ&#124;WRITE&#124;CREATE&#124;ADMIN] (ON [database]) TO [user]</code>
'''<code>HELP ([command])</code>'''
+
|-
 
+
| valign='top' | '''Summary'''
If <code>[command]</code> is specified, information on the specific
+
|Grants the specified [[User_Management#Permissions|permission]] to the specified <code>[user]</code>. If a <code>[database]</code> is specified, the permissions are only granted locally.
command is printed; otherwise, all commands are listed.
+
|}
<hr/>
+
==HELP==
===INFO===
+
{|
 
+
|-
'''<code>INFO ([DATABASE|INDEX|STORAGE])</code>'''
+
| valign='top' width='90' | '''Signature'''
 
+
|<code>HELP ([command])</code>
Shows information on the currently opened database:
+
|-
 +
| valign='top' | '''Summary'''
 +
|If <code>[command]</code> is specified, information on the specific command is printed; otherwise, all commands are listed.
 +
|}
 +
==INFO==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>INFO ([DATABASE&#124;INDEX&#124;STORAGE])</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Shows information on the currently opened database:
 
* <code>no argument</code>: Shows global information on the DBMS
 
* <code>no argument</code>: Shows global information on the DBMS
 
* <code>DATABASE</code>: Shows general database information
 
* <code>DATABASE</code>: Shows general database information
 
* <code>INDEX</code>: Shows information on the existing index structures
 
* <code>INDEX</code>: Shows information on the existing index structures
 
* <code>STORAGE [start end] | [query]</code>: Shows the main table of the internal storage
 
* <code>STORAGE [start end] | [query]</code>: Shows the main table of the internal storage
<hr/>
+
|}
===KILL===
+
==KILL==
 
+
{|
'''<code>KILL [name]</code>'''
+
|-
 
+
| valign='top' width='90' | '''Signature'''
Kills all sessions of the user specified by <code>[name]</code>.
+
|<code>KILL [name]</code>
<hr/>
+
|-
===LIST===
+
| valign='top' | '''Summary'''
 
+
|Kills all sessions of the user specified by <code>[name]</code>.
'''<code>LIST ([path])</code>'''
+
|}
 
+
==LIST==
Lists all available databases, or the documents in a database.
+
{|
<code>[path]</code> is the name of the database, optionally
+
|-
followed by a path to the requested documents.
+
| valign='top' width='90' | '''Signature'''
<hr/>
+
|<code>LIST ([path])</code>
===OPEN===
+
|-
 
+
| valign='top' | '''Summary'''
'''<code>OPEN [path]</code>'''
+
|Lists all available databases, or the documents in a database. <code>[path]</code> is the name of the database, optionally followed by a path to the requested documents.
 
+
|}
Opens the documents in a database.
+
==OPEN==
<code>[path]</code> is the name of the database, optionally
+
{|
followed by a path to the requested documents.
+
|-
<hr/>
+
| valign='top' width='90' | '''Signature'''
===OPTIMIZE===
+
|<code>OPEN [path]</code>
 
+
|-
'''<code>OPTIMIZE (ALL)</code>'''
+
| valign='top' | '''Summary'''
 
+
|Opens the documents in a database. <code>[path]</code> is the name of the database, optionally followed by a path to the requested documents.
Optimizes the current database structures. If the <code>ALL</code>
+
|}
flag is specified, the size of all database files is minimized.
+
==OPTIMIZE==
<hr/>
+
{|
===PASSWORD===
+
|-
 
+
| valign='top' width='90' | '''Signature'''
'''<code>PASSWORD ([password])</code>'''
+
|<code>OPTIMIZE (ALL)</code>
 
+
|-
Changes the <code>[password]</code> of the current user. If no password is
+
| valign='top' | '''Summary'''
specified in the console mode, it is requested via standard input.
+
|Optimizes the current database structures. If the <code>ALL</code> flag is specified, the size of all database files is minimized.
<hr/>
+
|}
===RESTORE===
+
==PASSWORD==
 
+
{|
'''<code>RESTORE [name]</code>'''
+
|-
 
+
| valign='top' width='90' | '''Signature'''
Restores a database with the specified [name]. The name may include the timestamp of the backup file.
+
|<code>PASSWORD ([password])</code>
<hr/>
+
|-
===RUN===
+
| valign='top' | '''Summary'''
 
+
|Changes the <code>[password]</code> of the current user. If no password is specified in the console mode, it is requested via standard input.
'''<code>RUN [path]</code>'''
+
|}
 
+
==RESTORE==
Runs the query file specified by <code>[path]</code> and prints the result.
+
{|
<hr/>
+
|-
===SET===
+
| valign='top' width='90' | '''Signature'''
 
+
|<code>RESTORE [name]</code>
'''<code>SET [option] ([value])</code>'''
+
|-
 
+
| valign='top' | '''Summary'''
Sets an <code>[option]</code> to the specified <code>[value]</code>.
+
|Restores a database with the specified [name]. The name may include the timestamp of the backup file.
A list of all options is [[Options|available here]].
+
|}
<hr/>
+
==RUN==
===SHOW===
+
{|
 
+
|-
'''<code>SHOW [DATABASES|SESSIONS|USERS|BACKUPS]</code>'''
+
| valign='top' width='90' | '''Signature'''
 
+
|<code>RUN [path]</code>
Shows server information:
+
|-
 +
| valign='top' | '''Summary'''
 +
|Runs the query file specified by <code>[path]</code> and prints the result.
 +
|}
 +
==SET==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>SET [option] ([value])</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Sets an <code>[option]</code> to the specified <code>[value]</code>. A list of all options is [[Options|available here]].
 +
|}
 +
==SHOW==
 +
{|
 +
|-
 +
| valign='top' width='90' | '''Signature'''
 +
|<code>SHOW [DATABASES&#124;SESSIONS&#124;USERS&#124;BACKUPS]</code>
 +
|-
 +
| valign='top' | '''Summary'''
 +
|Shows server information:
 
* <code>DATABASES</code>: Shows the currently opened databases.
 
* <code>DATABASES</code>: Shows the currently opened databases.
 
* <code>SESSIONS</code>: Shows the currently active database sessions.
 
* <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>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.
 
* <code>BACKUPS</code>: Shows all database backups.
<hr/>
+
|}
===XQUERY===
+
==XQUERY==
 
+
{|
'''<code>XQUERY [query]</code>'''
+
|-
 
+
| valign='top' width='90' | '''Signature'''
Runs the specified <code>[query]</code> and prints the result.
+
|<code>XQUERY [query]</code>
</div>
+
|-
<hr/>
+
| valign='top' | '''Summary'''
 +
|Runs the specified <code>[query]</code> and prints the result.
 +
|}
  
 
[[Category:Beginner]]
 
[[Category:Beginner]]
 
[[Category:Server]]
 
[[Category:Server]]
 
__NOTOC__
 

Revision as of 01:30, 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

Signature ALTER [USER|DATABASE] [...]
Summary Alters the password of a user, or the name of a database:
  • USER [name] ([password]):
Alters the [password] of the user specified with [name]. If no password is specified in the console mode, it is requested via standard input.
  • DATABASE [name] [newname]
Alters the [name] of a database to [newname].

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

Signature CREATE [DATABASE|INDEX|USER] [...]
Summary Creates a new database, index or user:
  • DATABASE [name] ([input]):
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.
  • INDEX [TEXT|ATTRIBUTE|FULLTEXT|PATH]:
Creates the specified index
  • USER [name] ([password]):
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

Signature DROP [DATABASE|INDEX|USER] [...]
Summary Drops a database, index or user:
  • DATABASE [name]:
Drops the database with the specified [name].
  • INDEX [PATH|TEXT|ATTRIBUTE|FULLTEXT]:
Drops the specified index.
  • USER [name] (ON [database]):
Drops the user with the specified [name]. If a [database] is specified, the user is only dropped locally.
  • BACKUP [name]:
Drops all backups for the database with the specified [name].

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 ([DATABASE|INDEX|STORAGE])
Summary Shows information on the currently opened database:
  • no argument: Shows global information on the DBMS
  • DATABASE: Shows general database information
  • INDEX: Shows information on the existing index structures
  • STORAGE [start end] | [query]: Shows the main table of the internal storage

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

Signature SHOW [DATABASES|SESSIONS|USERS|BACKUPS]
Summary Shows server information:
  • DATABASES: Shows the currently opened databases.
  • SESSIONS: Shows the currently active database sessions.
  • USERS (ON [database]): Shows all known users. If a [database] is specified, local users are shown.
  • BACKUPS: Shows all database backups.

XQUERY

Signature XQUERY [query]
Summary Runs the specified [query] and prints the result.