Changes

Jump to navigation Jump to search
644 bytes removed ,  22:57, 26 May 2012
no edit summary
rights are required by a user to perform a command in the client/server architecture.
A shortcut exists for some of the command keywords. For example, you may replace
the <code>{{Code|DATABASE</code> }} keyword with {{Code|DB}}. =Conventions= ==Glob Syntax== For some commands, the glob syntax can be used to address more than one database or user. Question marks and asterisks can be used to match one or more characters, and commas can be used to separate multiple patterns. Some examples: * {{Code|AB?}} addresses all names with the characters {{Code|AB}} and one more character.* {{Code|*AB}} addresses all names ending with the characters {{Code|AB}}.* {{Code|X*,Y*,Z*}} addresses all names starting with the characters {{Code|X}}, {{Code|Y}}, or {{Code|Z}}. ==Valid Names== Both database and user names must follow the same naming constraints. Valid names may contain letters, numbers, underscores and dashes. Names must have at least one character; they also should not be longer than 128 characters, although this is not enforced. A regular expression matching valid names is <code>DB[-_a-zA-Z0-9]{1,128}</code>. ==Shortcuts== In all commands, the {{Code|DATABASE}} keyword can be replaced by the shortcut {{Code|DB}}.
=Database Operations=
|-
| width='90' | '''Signature'''
|<code>{{Code|CREATE DATABASE [name] ([input])</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Creates the database <code>{{Code|[name]</code> }} with an optional <code>{{Code|[input]</code>}}.<br />The input may either be a reference to a single XML document, a directory, a remote URL, or a string containing XML. <code>{{Code|[name]</code> }} must be a [[#Valid Names|valid database name]].
|-
| '''Errors'''
| '''Examples'''
|
* <code>{{Code|CREATE DATABASE input</code>}}<br/>creates an empty database <code>{{Code|input</code>}}.* <code>{{Code|CREATE DATABASE xmark http://files.basex.org/xml/xmark.xml</code>}}<br/>creates the database <code>{{Code|xmark</code>}}, containing a single initial document called {{Code|xmark.xml}}.* <code>{{Code|CREATE DATABASE coll /path/to/input</code>}}<br/>creates the database <code>{{Code|coll</code> }} with all documents found in the <code>{{Code|input</code> }} directory.* <code>{{Code|SET INTPARSE false; CREATE DATABASE input input.xml</code>}}<br/>creates a database <code>{{Code|input</code> }} with {{Code|input.xml}} as initial document, which will be parsed with Java's [[Parsers#XML Parsers|default XML parser]].
|}
|-
| width='90' | '''Signature'''
|<code>{{Code|OPEN [path]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Opens a database or some of its documents. <code>{{Code|[path]</code> }} is the name of the database. If the name is further refined by a path, only some of the documents in the database will be opened.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|CHECK [input]</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|CLOSE </code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|EXPORT [path]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Exports all documents in the database to the specified <code>{{Code|[path]</code>}}, using the serializer options specified by the <code>[[Options#EXPORTER|EXPORTER]]</code> option.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|CREATE INDEX [TEXT&#124;ATTRIBUTE&#124;FULLTEXT]</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|DROP INDEX [TEXT&#124;ATTRIBUTE&#124;FULLTEXT]</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|ALTER DATABASE [name] [newname]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Renames the database specified by <code>{{Code|[name]</code> }} to <code>{{Code|[newname]</code>}}. <code>{{Code|[newname]</code> }} must be a [[#Valid Names|valid database name]].
|-
| '''Errors'''
| '''Examples'''
|
* <code>{{Code|ALTER DATABASE db tempdb</code>}}<br/>renames the database <code>{{Code|db</code> }} into <code>{{Code|tempdb</code>}}.
|}
|-
| width='90' | '''Signature'''
|<code>{{Code|DROP DATABASE [name]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Drops the database with the specified <code>{{Code|[name]</code>}}. The [[#Glob Syntax|Glob Syntax]] can be used to address more than one database.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|CREATE BACKUP [name]</code>}}
|-
| '''Permission'''
| '''Examples'''
|
* <code>{{Code|BACKUP db</code>}}<br/>creates a zip archive of the database <code>{{Code|db</code> }} (e.g. <code>{{Code|db-2011-04-01-12-27-28.zip</code>}}) in the [[Configuration#Database_Directory|database directory]].
|}
|-
| width='90' | '''Signature'''
|<code>{{Code|RESTORE [name]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Restores a database with the specified <code>{{Code|[name]</code>}}. The name may include the timestamp of the backup file.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|DROP BACKUP [name]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Drops all backups of the database with the specified <code>{{Code|[name]</code>}}. The [[#Glob Syntax|Glob Syntax]] can be used to address more than one database.
|-
| '''Examples'''
|
* <code>{{Code|DROP BACKUP abc*</code>}}<br/>deletes the backups of all databases starting with the characters <code>{{Code|abc</code>}}.
|}
|-
| width='90' | '''Signature'''
|<code>{{Code|SHOW BACKUPS</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|COPY [name] [newname]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Creates a copy of the database specified by <code>{{Code|[name]</code>}}. <code>{{Code|[newname]</code> }} must be a [[#Valid Names|valid database name]].
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|INFO DATABASE</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|INFO INDEX ([TEXT&#124;ATTRIBUTE&#124;FULLTEXT&#124;PATH])</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
| <code>{{Code|INFO STORAGE [start end] &#124; [query]</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|LIST ([path])</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Lists all available databases, or the documents in a database. <code>{{Code|[path]</code> }} is the name of the database, optionally followed by a path to the requested documents.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|XQUERY [query]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Runs the specified <code>{{Code|[query]</code> }} and prints the result.
|-
| '''Errors'''
| '''Examples'''
|
* <code>{{Code|XQUERY 1 to 10</code>}}<br/>returns the sequence <code>{{Code|(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)</code>}}.* <code>{{Code|SET RUNS 10; XQUERY 1 to 10</code>}}<br/>runs the query 10 times, returns the result and prints the average execution time.* <code>{{Code|SET XMLPLAN true; XQUERY 1 to 10</code>}}<br/>returns the result and prints the query plan as XML.
|}
|-
| width='90' | '''Signature'''
|<code>{{Code|RETRIEVE [path] [input]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Retrieves raw data from the specified database <code>{{Code|[path]</code>}}.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|RUN [file]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Runs the query contained in <code>{{Code|[file]</code> }} and prints the result.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|FIND [keywords]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Builds and runs a query for the specified <code>{{Code|[keywords]</code>}}. Keywords can be enclosed in quotes to look for phrases. The following modifiers can be used to further limit search:<code>{{Code|= </code> }} looks for exact text nodes<br/><code>{{Code|~ </code> }} looks for approximate hits<br/><code>{{Code|@=</code> }} looks for exact attribute values<br/><code>{{Code|@ </code> }} looks for attributes
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|CS [query]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Evaluates the specified <code>{{Code|[query]</code> }} and sets the result as new context set.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|REPO INSTALL [path]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
| Installs the package with path <code>{{Code|[path]</code>}}.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|REPO LIST</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|REPO DELETE [name&#124;dir]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
| Deletes the package with name <code>{{Code|[name]</code> }} or with directory <code>{{Code|[dir]</code>}}.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|ADD (TO [path]) [input]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Adds the files, directory or XML string specified by <code>{{Code|[input]</code> }} to the currently opened database at the specified <code>{{Code|[path]</code>}}.<br/><code>{{Code|[input]</code> }} may either be a single XML document, a directory, a remote URL or a plain XML string. If the path denotes a directory, it needs to be suffixed with a slash (<code>{{Code|/</code>}}).
|-
| '''Errors'''
| '''Examples'''
|
* <code>{{Code|ADD input.xml</code>}}<br/>adds the file <code>{{Code|input.xml</code> }} to the database.* <code>{{Code|ADD TO temp/one.xml input.xml</code>}}<br/>adds <code>{{Code|input.xml</code> }} to the database and moves it to <code>{{Code|temp/one.xml</code>}}.* <code>{{Code|ADD TO target/ xmldir</code>}}<br/>adds all files from the <code>{{Code|xmldir</code> }} directory to the database in the <code>{{Code|target</code> }} path.
|}
|-
| width='90' | '''Signature'''
|<code>{{Code|DELETE [path]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Deletes all documents from the currently opened database that start with the specified <code>{{Code|[path]</code>}}.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|RENAME [path] [newpath]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Renames all document paths in the currently opened database that start with the specified <code>{{Code|[path]</code>}}. The command may be used to either rename single documents or directories.
|-
| '''Errors'''
| '''Examples'''
|
* <code>{{Code|RENAME one.xml two.xml</code>}}<br/>renames the document <code>{{Code|one.xml</code> }} to <code>{{Code|two.xml</code>}}.* <code>{{Code|RENAME / TOP</code>}}<br/>moves all documents to a <code>{{Code|TOP</code> }} root directory.
|}
|-
| width='90' | '''Signature'''
|<code>{{Code|REPLACE [path] [input]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Replaces the documents in the currently opened database, addressed by <code>{{Code|[path]</code>}}, with the file or XML string specified by <code>{{Code|[input]</code>}}. The original file name and path is preserved by the operation.
|-
| '''Errors'''
| '''Examples'''
|
* <code>{{Code|REPLACE one.xml input.xml</code>}}<br/>replaces the document <code>{{Code|one.xml</code> }} with the contents of the file <code>{{Code|input.xml</code>}}.* <code>{{Code|REPLACE top.xml &lt;xml/&gt;</code>}}<br/>replaces the document <code>{{Code|top.xml</code> }} with the document <code>{{Code|&lt;xml/&gt;</code>}}.
|}
|-
| width='90' | '''Signature'''
|<code>{{Code|STORE (TO [path]) [input]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Stores raw data to the specified <code>{{Code|[path]</code>}}. <code>{{Code|[input]</code> }} may either be a file reference, a remote URL, or a plain string. If the path denotes a directory, it needs to be suffixed with a slash (<code>/<{{Code|/code>}}).
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|OPTIMIZE (ALL)</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|FLUSH</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|SHOW DATABASES</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|SHOW SESSIONS</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|SHOW USERS (ON [database])</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Shows all users that are registered in the database. If a <code>{{Code|[database]</code> }} is specified, local users are shown.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|KILL [target]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Kills sessions of a user or an IP:port combination, specified by <code>{{Code|[target]</code>}}. The [[#Glob Syntax|Glob Syntax]] can be used to address more than one user.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|CREATE EVENT [NAME]</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|SHOW EVENTS</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|DROP EVENT [NAME]</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|CREATE USER [name] ([password])</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Creates a user with the specified <code>{{Code|[name]</code> }} and <code>{{Code|[password]</code>}}. <code>{{Code|[name]</code> }} must be a [[#Valid Names|valid user name]]. The password must be a valid MD5 hash value. If no password is specified in the console mode, it is requested via standard input.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|ALTER USER [name] ([password])</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Alters the <code>{{Code|[password]</code> }} of the user specified by <code>{{Code|[name]</code>}}. The password must be a valid MD5 hash value. If no password is specified in the console mode, it is requested via standard input.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|DROP USER [name] (ON [database])</code>}}:
|-
| '''Permission'''
|-
| '''Summary'''
|Drops the user with the specified <code>{{Code|[name]</code>}}. If a <code>{{Code|[database]</code> }} is specified, the user is only dropped locally. The [[#Glob Syntax|Glob Syntax]] can be used to address more than one database or user.
|-
| '''Errors'''
|The command fails if <code>{{Code|admin</code> }} is specified as user name, if the specified user does not exist or is logged in, or if the optional database could not be opened for modification.
|}
|-
| width='90' | '''Signature'''
|<code>{{Code|GRANT [NONE&#124;READ&#124;WRITE&#124;CREATE&#124;ADMIN] (ON [database]) TO [user]</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Grants the specified [[User_Management|permission]] to the specified <code>{{Code|[user]</code>}}. If a <code>{{Code|[database]</code> }} is specified, the permissions are only granted locally. The [[#Glob Syntax|Glob Syntax]] can be used to address more than one database or user.
|-
| '''Errors'''
|The command fails if <code>{{Code|admin</code> }} is specified as user name, if the specified user does not exist, or if the optional database could not be opened for modification.
|-
| '''Examples'''
|
* <code>{{Code|GRANT READ TO JoeWinson</code>}}<br/>grants <code>{{Code|READ</code> }} permission to the user <code>{{Code|JoeWinson</code>}}.* <code>{{Code|GRANT WRITE ON Wiki TO editor*</code>}}<br/>grants <code>{{Code|WRITE</code> }} permissions on the <code>{{Code|Wiki</code> }} database to all users starting with the characters <code>{{Code|editor*</code>}}.
|}
|-
| width='90' | '''Signature'''
|<code>{{Code|PASSWORD ([password])</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Changes the <code>{{Code|[password]</code> }} of the current user. The password must be a valid MD5 hash value. If no password is specified in the console mode, it is requested via standard input.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|GET [option]</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|SET [option] ([value])</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|Sets the [[Options|Option]] with the specified <code>{{Code|[key]</code> }} to a new <code>{{Code|[value]</code>}}. If no value is specified, and if the value is boolean, it will be inverted.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|INFO</code>}}
|-
| '''Permission'''
|-
| width='90' | '''Signature'''
|<code>{{Code|HELP ([command])</code>}}
|-
| '''Permission'''
|-
| '''Summary'''
|If <code>{{Code|[command]</code> }} is specified, information on the specific command is printed; otherwise, all commands are listed.
|-
| '''Errors'''
|-
| width='90' | '''Signature'''
|<code>{{Code|EXIT </code>}}
|-
| '''Permission'''
|Exits the console mode.
|}
 
=Conventions=
 
==Glob Syntax==
 
For some commands, the glob syntax can be used to address more than one database or user. Question marks and asterisks can be used to match one or more characters, and commas can be used to separate multiple patterns. Some examples:
 
* <code>AB?</code> addresses all names with the characters <code>AB</code> and one more character.
* <code>*AB</code> addresses all names ending with the characters <code>AB</code>.
* <code>X*,Y*,Z*</code> addresses all names starting with the characters <code>X</code>, <code>Y</code>, or <code>Z</code>.
 
==Valid Names==
 
Both database and user names must follow the same naming constraints. Valid names may contain letters, numbers, underscores and dashes. Names must have at least one character; they also should not be longer than 128 characters, although this is not enforced. A regular expression matching valid names is <code>[-_a-zA-Z0-9]{1,128}</code>.
 
==Shortcuts==
 
In all commands, the {{Code|DATABASE}} keyword can be replaced by the shortcut {{Code|DB}}.
=Changelog=
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu