Difference between revisions of "Commands"

From BaseX Documentation
Jump to navigation Jump to search
(added WRITEBACK property to SET CMD)
Line 32: Line 32:
 
Opens the specified database [name].
 
Opens the specified database [name].
 
</p>  
 
</p>  
 
 
   
 
   
 
===Add===  
 
===Add===  
Line 40: Line 39:
 
[target] path.
 
[target] path.
 
</p>  
 
</p>  
 
 
   
 
   
 
===Delete===  
 
===Delete===  
Line 47: Line 45:
 
Deletes a document from the current database.
 
Deletes a document from the current database.
 
</p>  
 
</p>  
 
 
   
 
   
 
===Info===  
 
===Info===  
Line 71: Line 68:
 
Closes the current database.
 
Closes the current database.
 
</p>  
 
</p>  
 
 
   
 
   
 
===List===  
 
===List===  
Line 78: Line 74:
 
Lists all available databases.
 
Lists all available databases.
 
</p>  
 
</p>  
 
 
   
 
   
 
===Drop===  
 
===Drop===  
Line 103: Line 98:
 
Exports the database to [path].
 
Exports the database to [path].
 
</p>  
 
</p>  
 
 
   
 
   
 
===Optimize===  
 
===Optimize===  
Line 111: Line 105:
 
</p>  
 
</p>  
 
   
 
   
+
 
<br/>
 
 
==Query Commands==  
 
==Query Commands==  
 
===Xquery===  
 
===Xquery===  
Line 119: Line 112:
 
Evaluates the specified query and prints the result.
 
Evaluates the specified query and prints the result.
 
</p>  
 
</p>  
 
 
   
 
   
 
===Find===  
 
===Find===  
Line 126: Line 118:
 
The following modifiers can be used:
 
The following modifiers can be used:
 
</p>  
 
</p>  
 
 
   
 
   
 
===Run===  
 
===Run===  
Line 132: Line 123:
 
<code>RUN [path]</code><br/>  
 
<code>RUN [path]</code><br/>  
 
Evaluates an query from [path] and prints the result.
 
Evaluates an query from [path] and prints the result.
</p>  
+
</p>
 
 
   
 
   
 
===CS===  
 
===CS===  
Line 141: Line 131:
 
</p>  
 
</p>  
 
   
 
   
+
 
<br/>
 
 
==Admin Commands==  
 
==Admin Commands==  
 
===Show===  
 
===Show===  
Line 166: Line 155:
 
Grants permissions (on a database) to a user.
 
Grants permissions (on a database) to a user.
 
</p>  
 
</p>  
 
 
   
 
   
 
===Alter===  
 
===Alter===  
Line 188: Line 176:
 
Kills all sessions of the specified user.
 
Kills all sessions of the specified user.
 
</p>  
 
</p>  
 
 
   
 
   
 
===Backup===  
 
===Backup===  
Line 195: Line 182:
 
Creates a backup of the specified database.
 
Creates a backup of the specified database.
 
</p>  
 
</p>  
 
 
   
 
   
 
===Restore===  
 
===Restore===  
Line 203: Line 189:
 
</p>  
 
</p>  
 
   
 
   
+
 
<br/>
 
 
==General Commands==  
 
==General Commands==  
 
===Set===  
 
===Set===  
Line 243: Line 228:
 
Changes the user's password.
 
Changes the user's password.
 
</p>  
 
</p>  
 
 
   
 
   
 
===Help===  
 
===Help===  
Line 251: Line 235:
 
command is printed; otherwise, all commands are listed.
 
command is printed; otherwise, all commands are listed.
 
</p>  
 
</p>  
 
 
   
 
   
 
===Exit===  
 
===Exit===  

Revision as of 11:13, 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 the <a href='faq#5.4'>FAQ</a> 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.