Difference between revisions of "Commands"

From BaseX Documentation
Jump to navigation Jump to search
(Wikified the markup)
Line 1: Line 1:
<p>
+
 
Here you find a description of all database commands
 
Here you find a description of all database commands
 
which you can enter in the console mode, in the Command
 
which you can enter in the console mode, in the Command
text field in the GUI, or send to the BaseX server:</p>
+
text field in the GUI, or send to the BaseX server:
 
   
 
   
 
==Database Commands==  
 
==Database Commands==  
 
===Create===  
 
===Create===  
<p>
 
<code>CREATE [DB|FS|INDEX|USER] [...]</code><br/>
 
Creates a new database, index or user:
 
</p>
 
 
   
 
   
<ul>  
+
;<code>CREATE [DB|FS|INDEX|USER] [...]</code>
<li><code>DB [name] ([input])</code>: <br/>
+
:Creates a new database, index or user:
  creates the database <code>[name]</code> with an optional <code>[input]</code>  
+
 
</li>
+
;<code>DB [name] ([input])</code>:  
<li><code>INDEX [TEXT|ATTRIBUTE|FULLTEXT|PATH]</code>: <br/>
+
:creates the database <code>[name]</code> with an optional <code>[input]</code>  
  creates the specified index
+
</li>
+
;<code>INDEX [TEXT|ATTRIBUTE|FULLTEXT|PATH]</code>:  
<li><code>FS [name] [path] ([mountpoint] [backingstore])</code>: <br/>
+
:creates the specified index
  creates filesystem database <code>[name]</code> for <code>[path]</code>  
+
  (using <code>[mountpoint]</code> and <code>[backingstore]</code> if FUSE is activated)
+
;<code>FS [name] [path] ([mountpoint] [backingstore])</code>:  
</li>
+
:creates filesystem database <code>[name]</code> for <code>[path]</code> (using <code>[mountpoint]</code> and <code>[backingstore]</code> if FUSE is activated)
<li><code>USER [name] ([password])</code>: <br/>
+
  creates the specified user
+
;<code>USER [name] ([password])</code>:  
</li>
+
:creates the specified user
</ul>
+
 +
 
   
 
   
 
===Open===  
 
===Open===  
<p>
+
<code>OPEN [name]</code><br/>
+
;<code>OPEN [name]</code>
Opens the specified database [name].
+
:Opens the specified database [name].
</p>
+
 
   
 
   
 
===Add===  
 
===Add===  
<p>
+
<code>ADD (AS [name]) (TO [target]) [input]</code><br/>
+
;<code>ADD (AS [name]) (TO [target]) [input]</code>
Adds [input] as [name] to the database, using an optional
+
:Adds [input] as [name] to the database, using an optional [target] path.
[target] path.
+
</p>
 
 
   
 
   
 
===Delete===  
 
===Delete===  
<p>
+
<code>DELETE [name]</code><br/>
+
;<code>DELETE [name]</code>
Deletes a document from the current database.
+
:Deletes a document from the current database.
</p>
+
 
   
 
   
 
===Info===  
 
===Info===  
<p>
 
<code>INFO ([DB|INDEX|TABLE])</code><br/>
 
Shows information on the currently opened database:
 
</p>
 
 
   
 
   
<ul>  
+
;<code>INFO ([DB|INDEX|TABLE])</code>
<li><code>no argument</code>:  show global information<br/>
+
;Shows information on the currently opened database:
</li>
+
<li><code>DB</code>:  shows database information<br/>
+
* <code>no argument</code>:  show global information
</li>
+
<li><code>INDEX</code>:  shows index information<br/>
+
* <code>DB</code>:  shows database information
</li>
+
<li><code>TABLE [start end] | [query]</code>:  show internal database table<br/>
+
* <code>INDEX</code>:  shows index information
</li>
+
</ul>
+
* <code>TABLE [start end] | [query]</code>:  show internal database table
 +
 +
 
   
 
   
 
===Close===  
 
===Close===  
<p>
+
<code>CLOSE </code><br/>
+
;<code>CLOSE </code>
Closes the current database.
+
:Closes the current database.
</p>
+
 
   
 
   
 
===List===  
 
===List===  
<p>
+
<code>LIST </code><br/>
+
;<code>LIST </code>
Lists all available databases.
+
:Lists all available databases.
</p>
+
 
   
 
   
 
===Drop===  
 
===Drop===  
<p>
 
<code>DROP [DB|INDEX|USER] [...]</code><br/>
 
Drops a database, index or user:
 
</p>
 
 
   
 
   
<ul>  
+
;<code>DROP [DB|INDEX|USER] [...]</code>
<li><code>DB [name]</code>: <br/>
+
:Drops a database, index or user:
  drops the database
+
 
</li>
+
;<code>DB [name]</code>:
<li><code>INDEX [PATH|TEXT|ATTRIBUTE|FULLTEXT]</code>: <br/>
+
: drops the database
  drops the specified index
+
</li>
+
;<code>INDEX [PATH|TEXT|ATTRIBUTE|FULLTEXT]</code>:  
<li><code>USER [name]</code>: <br/>
+
:drops the specified index
  drops the specified user
+
</li>
+
;<code>USER [name]</code>:
</ul>
+
:drops the specified user
 +
 +
 
   
 
   
 
===Export===  
 
===Export===  
<p>
+
<code>EXPORT [path]</code><br/>  
+
;<code>EXPORT [path]</code>
Exports the database to [path].
+
:Exports the database to [path].
</p>
+
 
   
 
   
 
===Optimize===  
 
===Optimize===  
<p>
+
<code>OPTIMIZE </code><br/>  
+
;<code>OPTIMIZE </code>
Optimizes the current database structures.
+
:Optimizes the current database structures.
</p>
+
 
   
 
   
  
 
==Query Commands==  
 
==Query Commands==  
 
===Xquery===  
 
===Xquery===  
<p>
+
<code>XQUERY [query]</code><br/>
+
;<code>XQUERY [query]</code>
Evaluates the specified query and prints the result.
+
:Evaluates the specified query and prints the result.
</p>
+
 
   
 
   
 
===Find===  
 
===Find===  
<p>
+
<code>FIND [query]</code><br/>
+
;<code>FIND [query]</code>
The following modifiers can be used:
+
:The following modifiers can be used:
</p>
+
 
   
 
   
 
===Run===  
 
===Run===  
<p>
+
<code>RUN [path]</code><br/>
+
;<code>RUN [path]</code>
Evaluates an query from [path] and prints the result.
+
:Evaluates an query from [path] and prints the result.
</p>
+
 
 
   
 
   
 
===CS===  
 
===CS===  
<p>
+
<code>CS [query]</code><br/>
+
;<code>CS [query]</code>
Evaluates the query and sets the result as new context set.
+
:Evaluates the query and sets the result as new context set.
</p>
+
 
   
 
   
  
 
==Admin Commands==  
 
==Admin Commands==  
 
===Show===  
 
===Show===  
<p>
 
<code>SHOW [DATABASES|SESSIONS|USERS|BACKUPS]</code><br/>
 
Shows server information:
 
</p>
 
 
   
 
   
<ul>  
+
;<code>SHOW [DATABASES|SESSIONS|USERS|BACKUPS]</code>
<li><code>DATABASES</code>:  shows currently opened databases.<br/>
+
:Shows server information:
</li>
+
* <code>DATABASES</code>:  shows currently opened databases.  
<li><code>SESSIONS</code>:  shows current database sessions.<br/>
+
* <code>SESSIONS</code>:  shows current database sessions.
</li>
+
* <code>USERS (ON [db])</code>:  shows users (on a database).
<li><code>USERS (ON [db])</code>:  shows users (on a database).<br/>
+
* <code>BACKUPS</code>:  shows backups.
</li>
+
<li><code>BACKUPS</code>:  shows backups.<br/>
+
</li>
 
</ul>
 
 
   
 
   
 
===Grant===  
 
===Grant===  
<p>
+
<code>GRANT [NONE|READ|WRITE|CREATE|ADMIN] (ON [db]) TO [user]</code><br/>
+
;<code>GRANT [NONE|READ|WRITE|CREATE|ADMIN] (ON [db]) TO [user]</code>
Grants permissions (on a database) to a user.
+
:Grants permissions (on a database) to a user.
</p>
+
 
   
 
   
 
===Alter===  
 
===Alter===  
<p>
 
<code>ALTER [USER|DB] [...]</code><br/>
 
Alters user password or database name:
 
</p>
 
 
   
 
   
<ul>  
+
;<code>ALTER [USER|DB] [...]</code>
<li><code>USER [name] ([password])</code>: <br/>
+
:Alters user password or database name:
  alters the password of a user.
+
</li>
+
; <code>USER [name] ([password])</code>:  
<li><code>DB [name] [newname]</code>: <br/>
+
: alters the password of a user.
  alters the name of a database.
+
</li>
+
; <code>DB [name] [newname]</code>:  
</ul>
+
: alters the name of a database.
 +
 +
 
   
 
   
 
===Kill===  
 
===Kill===  
<p>
+
<code>KILL [name]</code><br/>
+
;<code>KILL [name]</code>
Kills all sessions of the specified user.
+
:Kills all sessions of the specified user.
</p>
+
 
   
 
   
 
===Backup===  
 
===Backup===  
<p>
+
<code>BACKUP [name]</code><br/>
+
;<code>BACKUP [name]</code>
Creates a backup of the specified database.
+
:Creates a backup of the specified database.
</p>
+
 
   
 
   
 
===Restore===  
 
===Restore===  
<p>
+
<code>RESTORE [name]</code><br/>
+
;<code>RESTORE [name]</code>
Restores a backup of the specified database.
+
:Restores a backup of the specified database.
</p>
+
 
   
 
   
  
 
==General Commands==  
 
==General Commands==  
 
===Set===  
 
===Set===  
<p>
 
<code>SET [option] ([value])</code><br/>
 
Available options [option] with value [value] = on/off:
 
</p>
 
 
   
 
   
<ul>  
+
;<code>SET [option] ([value])</code>
<li><code>QUERYINFO</code>:  Display of query info<br/>
+
:Available options [option] with value [value] = on/off:
</li>
+
* <code>QUERYINFO</code>:  Display of query info
<li><code>DEBUG</code>:  Display of debug info<br/>
+
* <code>DEBUG</code>:  Display of debug info
</li>
+
* <code>SERIALIZE</code>:  Serialization of query results
<li><code>SERIALIZE</code>:  Serialization of query results<br/>
+
* <code>CHOP</code>:  Chopping of XML whitespaces
</li>
+
* <code>ENTITY</code>:  Parsing of XML entities
<li><code>CHOP</code>:  Chopping of XML whitespaces<br/>
+
* <code>TEXTINDEX</code>:  Text indexing
</li>
+
* <code>ATTRINDEX</code>:  Attribute value indexing
<li><code>ENTITY</code>:  Parsing of XML entities<br/>
+
* <code>FTINDEX</code>:  Full-text indexing
</li>
+
* <code>PATHINDEX</code>:  Path indexing
<li><code>TEXTINDEX</code>:  Text indexing<br/>
+
* <code>WRITEBACK</code>:  Propagating changes to input file
</li>
+
 
<li><code>ATTRINDEX</code>:  Attribute value indexing<br/>
+
</li>
 
<li><code>FTINDEX</code>:  Full-text indexing<br/>
 
</li>
 
<li><code>PATHINDEX</code>:  Path indexing<br/>
 
</li>
 
<li><code>WRITEBACK</code>:  Propagating changes to input file<br/>
 
</li>
 
</ul>
 
 
   
 
   
 
Have a look into [[Settings]] to find
 
Have a look into [[Settings]] to find
a complete list of available options.<br />
+
a complete list of available options.
 +
 
  
 
===Password===  
 
===Password===  
<p>
+
<code>PASSWORD ([password])</code><br/>  
+
;<code>PASSWORD ([password])</code>
Changes the user's password.
+
:Changes the user's password.
</p>
+
 
   
 
   
 
===Help===  
 
===Help===  
<p>
+
<code>HELP ([command])</code><br/>  
+
;<code>HELP ([command])</code>
If [command] is specified, information on the specific
+
:If [command] is specified, information on the specific command is printed; otherwise, all commands are listed.
command is printed; otherwise, all commands are listed.
+
</p>
 
 
   
 
   
 
===Exit===  
 
===Exit===  
<p>
+
<code>EXIT </code><br/>
+
;<code>EXIT </code>
Exits BaseX.
+
:Exits BaseX.
</p>
 

Revision as of 11:45, 7 December 2010

Here you find a description of all database commands which you can enter in the console mode, in the Command text field in the GUI, or send to the BaseX server:

Database Commands

Create

CREATE [DB|FS|INDEX|USER] [...]
Creates a new database, index or user:
DB [name] ([input])
creates the database [name] with an optional [input]
INDEX [TEXT|ATTRIBUTE|FULLTEXT|PATH]
creates the specified index
FS [name] [path] ([mountpoint] [backingstore])
creates filesystem database [name] for [path] (using [mountpoint] and [backingstore] if FUSE is activated)
USER [name] ([password])
creates the specified user


Open

OPEN [name]
Opens the specified database [name].


Add

ADD (AS [name]) (TO [target]) [input]
Adds [input] as [name] to the database, using an optional [target] path.


Delete

DELETE [name]
Deletes a document from the current database.


Info

INFO ([DB|INDEX|TABLE])
Shows information on the currently opened database
  • no argument: show global information
  • DB: shows database information
  • INDEX: shows index information
  • TABLE [start end] | [query]: show internal database table


Close

CLOSE
Closes the current database.


List

LIST
Lists all available databases.


Drop

DROP [DB|INDEX|USER] [...]
Drops a database, index or user:
DB [name]
drops the database
INDEX [PATH|TEXT|ATTRIBUTE|FULLTEXT]
drops the specified index
USER [name]
drops the specified user


Export

EXPORT [path]
Exports the database to [path].


Optimize

OPTIMIZE
Optimizes the current database structures.


Query Commands

Xquery

XQUERY [query]
Evaluates the specified query and prints the result.


Find

FIND [query]
The following modifiers can be used:


Run

RUN [path]
Evaluates an query from [path] and prints the result.


CS

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


Admin Commands

Show

SHOW [DATABASES|SESSIONS|USERS|BACKUPS]
Shows server information:
  • DATABASES: shows currently opened databases.
  • SESSIONS: shows current database sessions.
  • USERS (ON [db]): shows users (on a database).
  • BACKUPS: shows backups.


Grant

GRANT [NONE|READ|WRITE|CREATE|ADMIN] (ON [db]) TO [user]
Grants permissions (on a database) to a user.


Alter

ALTER [USER|DB] [...]
Alters user password or database name:
USER [name] ([password])
alters the password of a user.
DB [name] [newname]
alters the name of a database.


Kill

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


Backup

BACKUP [name]
Creates a backup of the specified database.


Restore

RESTORE [name]
Restores a backup of the specified database.


General Commands

Set

SET [option] ([value])
Available options [option] with value [value] = on/off:
  • QUERYINFO: Display of query info
  • DEBUG: Display of debug info
  • SERIALIZE: Serialization of query results
  • CHOP: Chopping of XML whitespaces
  • ENTITY: Parsing of XML entities
  • TEXTINDEX: Text indexing
  • ATTRINDEX: Attribute value indexing
  • FTINDEX: Full-text indexing
  • PATHINDEX: Path indexing
  • WRITEBACK: Propagating changes to input file


Have a look into Settings to find a complete list of available options.


Password

PASSWORD ([password])
Changes the user's password.


Help

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


Exit

EXIT
Exits BaseX.