Difference between revisions of "Commands"

From BaseX Documentation
Jump to navigation Jump to search
Line 1: Line 1:
 
This page lists all commands that are supported by BaseX.
 
This page lists all commands that are supported by BaseX.
Commands can be either run from [[Startup_Options#BaseX_Standalone|command line]] or from the input field in the [[GUI_Tutorial|GUI]] frontend. If commands are triggered by the GUI itself, they will be listed in the [[GUI_Views|Info View]].
+
Commands can be either run from [[Startup_Options#BaseX_Standalone|command line]] or from the input field in the [[GUI_Tutorial|GUI]]. Commands, which are triggered by the GUI itself, will show up in the [[GUI_Views|Info View]].
  
 +
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%;">
 
<div style="float:left; width:48%;">
 
 
===ADD===
 
===ADD===
  
Line 11: Line 13:
 
<code>[target]</code> path and an optional file <code>[name]</code>.
 
<code>[target]</code> path and an optional file <code>[name]</code>.
  
 +
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.
 +
<hr/>
 
===ALTER===
 
===ALTER===
  
Line 17: Line 22:
 
Alters the password of a user, or the name of a database:
 
Alters the password of a user, or the name of a database:
 
* <code>USER [name] ([password])</code>:
 
* <code>USER [name] ([password])</code>:
: alters the [password] of the user specified with [name].
+
: 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 [name] of a database to [newname].
+
: Alters the <code>[name]</code> of a database to <code>[newname]</code>.
 
+
<hr/>
 
===BACKUP===
 
===BACKUP===
  
 
'''<code>BACKUP [name]</code>'''
 
'''<code>BACKUP [name]</code>'''
  
Creates a backup of the specified database.
+
Creates a zipped backup of the specified database. The backup file will be suffixed with the current timestamp.
 
+
<hr/>
 
===CHECK===
 
===CHECK===
  
 
'''<code>CHECK [input]</code>'''
 
'''<code>CHECK [input]</code>'''
  
Opens an existing database or creates a new instance.
+
Opens an existing database for the specified <code>[input]</code> or creates a new instance.
 
+
<hr/>
 
===CLOSE===
 
===CLOSE===
  
Line 38: Line 43:
  
 
Closes the currently opened database.
 
Closes the currently opened database.
 
+
<hr/>
 
===COPY===
 
===COPY===
  
 
'''<code>COPY [name] [newname]</code>'''
 
'''<code>COPY [name] [newname]</code>'''
  
Creates an identical database copy.
+
Creates an identical copy of the specified database.
 
+
<hr/>
 
===CREATE===
 
===CREATE===
  
Line 51: Line 56:
 
Creates a new database, index or user:
 
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.
 
* <code>INDEX [TEXT|ATTRIBUTE|FULLTEXT|PATH]</code>:
 
* <code>INDEX [TEXT|ATTRIBUTE|FULLTEXT|PATH]</code>:
: creates the specified index
+
: Creates the specified index
 
* <code>USER [name] ([password])</code>:
 
* <code>USER [name] ([password])</code>:
: creates the specified user
+
: 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>'''
 
'''<code>CS [query]</code>'''
  
Evaluates the query and sets the result as new context set.
+
Evaluates the specified <code>[query]</code> and sets the result as new context set.
 
+
<hr/>
 
===DELETE===
 
===DELETE===
  
'''<code>DELETE [name]</code>'''
+
'''<code>DELETE [path]</code>'''
 
 
Deletes documents from the currently opened database.
 
  
 +
Deletes all documents from the currently opened database that start with the specified <code>[path]</code>.
 +
<hr/>
 
===DROP===
 
===DROP===
  
'''<code>DROP [DB|INDEX|USER] [...]</code>'''
+
'''<code>DROP [DATABASE|INDEX|USER] [...]</code>'''
  
 
Drops a database, index or user:
 
Drops a database, index or user:
* <code>DB [name]</code>:
+
* <code>DATABASE [name]</code>:
: drops the database
+
: Drops the database with the specified <code>[name]</code>.
 
* <code>INDEX [PATH|TEXT|ATTRIBUTE|FULLTEXT]</code>:
 
* <code>INDEX [PATH|TEXT|ATTRIBUTE|FULLTEXT]</code>:
: drops the specified index
+
: Drops the specified index.
* <code>USER [name] (ON [db])</code>:
+
* <code>USER [name] (ON [database])</code>:
: drops the specified user (on a database)
+
: 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>:
 
* <code>BACKUP [name]</code>:
: drops the database backup
+
: Drops all backups for the database with the specified <code>[name]</code>.
 
+
<hr/>
 
===EXIT===
 
===EXIT===
  
 
'''<code>EXIT </code>'''
 
'''<code>EXIT </code>'''
  
Exits the BaseX console.
+
Exits the console mode.
 
+
<hr/>
 
===EXPORT===
 
===EXPORT===
  
 
'''<code>EXPORT [path]</code>'''
 
'''<code>EXPORT [path]</code>'''
  
Exports the database to <code>[path]</code>.
+
Exports all documents in the database to the specified <code>[path]</code>.
  
 +
</div><div style="float:left; width:4%;">&nbsp;
 +
</div><div style="float:left; width:48%;">
 
===FIND===
 
===FIND===
  
'''<code>FIND [query]</code>'''
+
'''<code>FIND [keywords]</code>'''
  
The following modifiers can be used:
+
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/>
</div><div style="float:left; width:4%;">&nbsp;
 
</div><div style="float:left; width:48%;">
 
 
 
 
===GET===
 
===GET===
  
 
'''<code>GET [option]</code>'''
 
'''<code>GET [option]</code>'''
  
Shows the value of a global option. A list of all options is [[Options|available here]].
+
Returns the value of the specified <code>[option]</code>. A list of all options is [[Options|available here]].
 
+
<hr/>
 
===GRANT===
 
===GRANT===
  
'''<code>GRANT [NONE|READ|WRITE|CREATE|ADMIN] (ON [db]) TO [user]</code>'''
+
'''<code>GRANT [NONE|READ|WRITE|CREATE|ADMIN] (ON [database]) TO [user]</code>'''
 
 
Grants permissions (on a database) to a user.
 
  
 +
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===
 
===HELP===
  
Line 125: Line 130:
 
If <code>[command]</code> is specified, information on the specific
 
If <code>[command]</code> is specified, information on the specific
 
command is printed; otherwise, all commands are listed.
 
command is printed; otherwise, all commands are listed.
 
+
<hr/>
 
===INFO===
 
===INFO===
  
'''<code>INFO ([DB|INDEX|STORAGE])</code>'''
+
'''<code>INFO ([DATABASE|INDEX|STORAGE])</code>'''
  
 
Shows information on the currently opened database:
 
Shows information on the currently opened database:
* <code>no argument</code>: show global information
+
* <code>no argument</code>: Shows global information on the DBMS
* <code>DB</code>: shows database information
+
* <code>DATABASE</code>: Shows general database information
* <code>INDEX</code>: shows index information
+
* <code>INDEX</code>: Shows information on the existing index structures
* <code>STORAGE [start end] | [query]</code>: show internal database table
+
* <code>STORAGE [start end] | [query]</code>: Shows the main table of the internal storage
 
+
<hr/>
 
===KILL===
 
===KILL===
  
 
'''<code>KILL [name]</code>'''
 
'''<code>KILL [name]</code>'''
  
Kills all sessions of the specified user.
+
Kills all sessions of the user specified by <code>[name]</code>.
 
+
<hr/>
 
===LIST===
 
===LIST===
  
 
'''<code>LIST ([path])</code>'''
 
'''<code>LIST ([path])</code>'''
  
Lists all available databases, or the documents
+
Lists all available databases, or the documents in a database.
within a database [path].
+
<code>[path]</code> is the name of the database, optionally
 
+
followed by a path to the requested documents.
 +
<hr/>
 
===OPEN===
 
===OPEN===
  
'''<code>OPEN [name]</code>'''
+
'''<code>OPEN [path]</code>'''
 
 
Opens the specified database <code>[name]</code>.
 
  
 +
Opens the documents in a database.
 +
<code>[path]</code> is the name of the database, optionally
 +
followed by a path to the requested documents.
 +
<hr/>
 
===OPTIMIZE===
 
===OPTIMIZE===
  
 
'''<code>OPTIMIZE (ALL)</code>'''
 
'''<code>OPTIMIZE (ALL)</code>'''
  
Optimizes the current database structures. If the <code>ALL</code> flag is specified, the size of all database files is minimized.
+
Optimizes the current database structures. If the <code>ALL</code>
 
+
flag is specified, the size of all database files is minimized.
 +
<hr/>
 
===PASSWORD===
 
===PASSWORD===
  
 
'''<code>PASSWORD ([password])</code>'''
 
'''<code>PASSWORD ([password])</code>'''
  
Changes the user's password.
+
Changes the <code>[password]</code> of the current user. If no password is
 
+
specified in the console mode, it is requested via standard input.
 +
<hr/>
 
===RESTORE===
 
===RESTORE===
  
 
'''<code>RESTORE [name]</code>'''
 
'''<code>RESTORE [name]</code>'''
  
Restores a backup of the specified database.
+
Restores a database with the specified [name]. The name may include the timestamp of the backup file.
 
+
<hr/>
 
===RUN===
 
===RUN===
  
 
'''<code>RUN [path]</code>'''
 
'''<code>RUN [path]</code>'''
  
Evaluates an query from <code>[path]</code> and prints the result.
+
Runs the query file specified by <code>[path]</code> and prints the result.
 
+
<hr/>
 
===SET===
 
===SET===
  
 
'''<code>SET [option] ([value])</code>'''
 
'''<code>SET [option] ([value])</code>'''
  
Available options <code>[option]</code> with value <code>[value]</code> = on/off:
+
Sets an <code>[option]</code> to the specified <code>[value]</code>.
* <code>QUERYINFO</code>: Display query info
 
* <code>DEBUG</code>: Display debug info
 
* <code>SERIALIZE</code>: Serialize query results
 
* <code>CHOP</code>: Chopp XML whitespaces
 
* <code>ENTITY</code>: Parse XML entities
 
* <code>TEXTINDEX</code>: Turn on/off text indexing
 
* <code>ATTRINDEX</code>: Turn on/off attribute value indexing
 
* <code>FTINDEX</code>: Turn on/off full-text indexing
 
* <code>PATHINDEX</code>: Turn on/off path indexing
 
 
 
 
A list of all options is [[Options|available here]].
 
A list of all options is [[Options|available here]].
 
+
<hr/>
 
===SHOW===
 
===SHOW===
  
Line 201: Line 201:
  
 
Shows server information:
 
Shows server information:
* <code>DATABASES</code>: shows currently opened databases.
+
* <code>DATABASES</code>: Shows the currently opened databases.
* <code>SESSIONS</code>: shows current database sessions.
+
* <code>SESSIONS</code>: Shows the currently active database sessions.
* <code>USERS (ON [db])</code>: shows users (on a database).
+
* <code>USERS (ON [database])</code>: Shows all known users. If a <code>[database]</code> is specified, local users are shown.
* <code>BACKUPS</code>: shows backups.
+
* <code>BACKUPS</code>: Shows all database backups.
 
+
<hr/>
 
===XQUERY===
 
===XQUERY===
  
 
'''<code>XQUERY [query]</code>'''
 
'''<code>XQUERY [query]</code>'''
  
Evaluates the specified query and prints the result.
+
Runs the specified <code>[query]</code> and prints the result.
 
</div>
 
</div>
 +
<hr/>
  
 
[[Category:Beginner]]
 
[[Category:Beginner]]

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

ADD (AS [name]) (TO [target]) [input]

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

ALTER [USER|DATABASE] [...]

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

BACKUP [name]

Creates a zipped backup of the specified database. The backup file will be suffixed with the current timestamp.


CHECK

CHECK [input]

Opens an existing database for the specified [input] or creates a new instance.


CLOSE

CLOSE

Closes the currently opened database.


COPY

COPY [name] [newname]

Creates an identical copy of the specified database.


CREATE

CREATE [DATABASE|INDEX|USER] [...]

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

CS [query]

Evaluates the specified [query] and sets the result as new context set.


DELETE

DELETE [path]

Deletes all documents from the currently opened database that start with the specified [path].


DROP

DROP [DATABASE|INDEX|USER] [...]

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

EXIT

Exits the console mode.


EXPORT

EXPORT [path]

Exports all documents in the database to the specified [path].

 

FIND

FIND [keywords]

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

GET [option]

Returns the value of the specified [option]. A list of all options is available here.


GRANT

GRANT [NONE|READ|WRITE|CREATE|ADMIN] (ON [database]) TO [user]

Grants the specified permission to the specified [user]. If a [database] is specified, the permissions are only granted locally.


HELP

HELP ([command])

If [command] is specified, information on the specific command is printed; otherwise, all commands are listed.


INFO

INFO ([DATABASE|INDEX|STORAGE])

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

KILL [name]

Kills all sessions of the user specified by [name].


LIST

LIST ([path])

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

OPEN [path]

Opens the documents in a database. [path] is the name of the database, optionally followed by a path to the requested documents.


OPTIMIZE

OPTIMIZE (ALL)

Optimizes the current database structures. If the ALL flag is specified, the size of all database files is minimized.


PASSWORD

PASSWORD ([password])

Changes the [password] of the current user. If no password is specified in the console mode, it is requested via standard input.


RESTORE

RESTORE [name]

Restores a database with the specified [name]. The name may include the timestamp of the backup file.


RUN

RUN [path]

Runs the query file specified by [path] and prints the result.


SET

SET [option] ([value])

Sets an [option] to the specified [value]. A list of all options is available here.


SHOW

SHOW [DATABASES|SESSIONS|USERS|BACKUPS]

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

XQUERY [query]

Runs the specified [query] and prints the result.