Author: tylerhobbs
Date: Tue Jun 16 17:25:32 2015
New Revision: 1685873
URL: http://svn.apache.org/r1685873
Log:
Update 2.1 CQL docs to the latest
Modified:
cassandra/site/publish/doc/cql3/CQL-2.1.html
Modified: cassandra/site/publish/doc/cql3/CQL-2.1.html
URL:
http://svn.apache.org/viewvc/cassandra/site/publish/doc/cql3/CQL-2.1.html?rev=1685873&r1=1685872&r2=1685873&view=diff
==============================================================================
--- cassandra/site/publish/doc/cql3/CQL-2.1.html (original)
+++ cassandra/site/publish/doc/cql3/CQL-2.1.html Tue Jun 16 17:25:32 2015
@@ -1,4 +1,4 @@
-<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html
xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type"
content="text/html; charset=utf-8"/><title>CQL</title></head><body><p><link
rel="StyleSheet" href="CQL.css" type="text/css" media="screen"></p><h1
id="CassandraQueryLanguageCQLv3.2.0">Cassandra Query Language (CQL)
v3.2.0</h1><span id="tableOfContents"><ol style="list-style: none;"><li><a
href="CQL.html#CassandraQueryLanguageCQLv3.2.0">Cassandra Query Language (CQL)
v3.2.0</a><ol style="list-style: none;"><li><a href="CQL.html#CQLSyntax">CQL
Syntax</a><ol style="list-style: none;"><li><a
href="CQL.html#Preamble">Preamble</a></li><li><a
href="CQL.html#Conventions">Conventions</a></li><li><a
href="CQL.html#identifiers">Identifiers and keywords</a></li><li><a
href="CQL.html#constants">Constants</a></li><li><a
href="CQL.html#Comments">Comments</a></l
i><li><a href="CQL.html#statements">Statements</a></li><li><a
href="CQL.html#preparedStatement">Prepared Statement</a></li></ol></li><li><a
href="CQL.html#dataDefinition">Data Definition</a><ol style="list-style:
none;"><li><a href="CQL.html#createKeyspaceStmt">CREATE KEYSPACE</a></li><li><a
href="CQL.html#useStmt">USE</a></li><li><a
href="CQL.html#alterKeyspaceStmt">ALTER KEYSPACE</a></li><li><a
href="CQL.html#dropKeyspaceStmt">DROP KEYSPACE</a></li><li><a
href="CQL.html#createTableStmt">CREATE TABLE</a></li><li><a
href="CQL.html#alterTableStmt">ALTER TABLE</a></li><li><a
href="CQL.html#dropTableStmt">DROP TABLE</a></li><li><a
href="CQL.html#truncateStmt">TRUNCATE</a></li><li><a
href="CQL.html#createIndexStmt">CREATE INDEX</a></li><li><a
href="CQL.html#dropIndexStmt">DROP INDEX</a></li><li><a
href="CQL.html#createTypeStmt">CREATE TYPE</a></li><li><a
href="CQL.html#alterTypeStmt">ALTER TYPE</a></li><li><a
href="CQL.html#dropTypeStmt">DROP TYPE</a></li><li><a href="CQL.html#createTri
ggerStmt">CREATE TRIGGER</a></li><li><a href="CQL.html#dropTriggerStmt">DROP
TRIGGER</a></li></ol></li><li><a href="CQL.html#dataManipulation">Data
Manipulation</a><ol style="list-style: none;"><li><a
href="CQL.html#insertStmt">INSERT</a></li><li><a
href="CQL.html#updateStmt">UPDATE</a></li><li><a
href="CQL.html#deleteStmt">DELETE</a></li><li><a
href="CQL.html#batchStmt">BATCH</a></li></ol></li><li><a
href="CQL.html#queries">Queries</a><ol style="list-style: none;"><li><a
href="CQL.html#selectStmt">SELECT</a></li></ol></li><li><a
href="CQL.html#types">Data Types</a><ol style="list-style: none;"><li><a
href="CQL.html#usingdates">Working with dates</a></li><li><a
href="CQL.html#counters">Counters</a></li><li><a
href="CQL.html#collections">Working with collections</a></li></ol></li><li><a
href="CQL.html#functions">Functions</a><ol style="list-style: none;"><li><a
href="CQL.html#tokenFun">Token</a></li><li><a
href="CQL.html#uuidFun">Uuid</a></li><li><a href="CQL.html#timeuuidFun">Timeuu
id functions</a></li><li><a href="CQL.html#blobFun">Blob conversion
functions</a></li></ol></li><li><a href="CQL.html#appendixA">Appendix A: CQL
Keywords</a></li><li><a href="CQL.html#appendixB">Appendix B: CQL Reserved
Types</a></li><li><a href="CQL.html#changes">Changes</a><ol style="list-style:
none;"><li><a href="CQL.html#a3.2.0">3.2.0</a></li><li><a
href="CQL.html#a3.1.7">3.1.7</a></li><li><a
href="CQL.html#a3.1.6">3.1.6</a></li><li><a
href="CQL.html#a3.1.5">3.1.5</a></li><li><a
href="CQL.html#a3.1.4">3.1.4</a></li><li><a
href="CQL.html#a3.1.3">3.1.3</a></li><li><a
href="CQL.html#a3.1.2">3.1.2</a></li><li><a
href="CQL.html#a3.1.1">3.1.1</a></li><li><a
href="CQL.html#a3.1.0">3.1.0</a></li><li><a
href="CQL.html#a3.0.5">3.0.5</a></li><li><a
href="CQL.html#a3.0.4">3.0.4</a></li><li><a
href="CQL.html#a3.0.3">3.0.3</a></li><li><a
href="CQL.html#a3.0.2">3.0.2</a></li><li><a
href="CQL.html#a3.0.1">3.0.1</a></li></ol></li><li><a
href="CQL.html#Versioning">Versioning</a></li></ol></li></
ol></span><h2 id="CQLSyntax">CQL Syntax</h2><h3
id="Preamble">Preamble</h3><p>This document describes the Cassandra Query
Language (CQL) version 3. CQL v3 is not backward compatible with CQL v2 and
differs from it in numerous ways. Note that this document describes the last
version of the languages. However, the <a href="#changes">changes</a> section
provides the diff between the different versions of CQL v3.</p><p>CQL v3 offers
a model very close to SQL in the sense that data is put in <em>tables</em>
containing <em>rows</em> of <em>columns</em>. For that reason, when used in
this document, these terms (tables, rows and columns) have the same definition
than they have in SQL. But please note that as such, they do
<strong>not</strong> refer to the concept of rows and columns found in the
internal implementation of Cassandra and in the thrift and CQL v2 API.</p><h3
id="Conventions">Conventions</h3><p>To aid in specifying the CQL syntax, we
will use the following conventions in this d
ocument:</p><ul><li>Language rules will be given in a <a
href="http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form">BNF</a> -like
notation:</li></ul><pre class="syntax"><pre><start> ::= TERMINAL
<non-terminal1> <non-terminal1>
+<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html
xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type"
content="text/html; charset=utf-8"/><title>CQL</title></head><body><p><link
rel="StyleSheet" href="CQL.css" type="text/css" media="screen"></p><h1
id="CassandraQueryLanguageCQLv3.2.0">Cassandra Query Language (CQL)
v3.2.0</h1><span id="tableOfContents"><ol style="list-style: none;"><li><a
href="CQL.html#CassandraQueryLanguageCQLv3.2.0">Cassandra Query Language (CQL)
v3.2.0</a><ol style="list-style: none;"><li><a href="CQL.html#CQLSyntax">CQL
Syntax</a><ol style="list-style: none;"><li><a
href="CQL.html#Preamble">Preamble</a></li><li><a
href="CQL.html#Conventions">Conventions</a></li><li><a
href="CQL.html#identifiers">Identifiers and keywords</a></li><li><a
href="CQL.html#constants">Constants</a></li><li><a
href="CQL.html#Comments">Comments</a></l
i><li><a href="CQL.html#statements">Statements</a></li><li><a
href="CQL.html#preparedStatement">Prepared Statement</a></li></ol></li><li><a
href="CQL.html#dataDefinition">Data Definition</a><ol style="list-style:
none;"><li><a href="CQL.html#createKeyspaceStmt">CREATE KEYSPACE</a></li><li><a
href="CQL.html#useStmt">USE</a></li><li><a
href="CQL.html#alterKeyspaceStmt">ALTER KEYSPACE</a></li><li><a
href="CQL.html#dropKeyspaceStmt">DROP KEYSPACE</a></li><li><a
href="CQL.html#createTableStmt">CREATE TABLE</a></li><li><a
href="CQL.html#alterTableStmt">ALTER TABLE</a></li><li><a
href="CQL.html#dropTableStmt">DROP TABLE</a></li><li><a
href="CQL.html#truncateStmt">TRUNCATE</a></li><li><a
href="CQL.html#createIndexStmt">CREATE INDEX</a></li><li><a
href="CQL.html#dropIndexStmt">DROP INDEX</a></li><li><a
href="CQL.html#createTypeStmt">CREATE TYPE</a></li><li><a
href="CQL.html#alterTypeStmt">ALTER TYPE</a></li><li><a
href="CQL.html#dropTypeStmt">DROP TYPE</a></li><li><a href="CQL.html#createTri
ggerStmt">CREATE TRIGGER</a></li><li><a href="CQL.html#dropTriggerStmt">DROP
TRIGGER</a></li></ol></li><li><a href="CQL.html#dataManipulation">Data
Manipulation</a><ol style="list-style: none;"><li><a
href="CQL.html#insertStmt">INSERT</a></li><li><a
href="CQL.html#updateStmt">UPDATE</a></li><li><a
href="CQL.html#deleteStmt">DELETE</a></li><li><a
href="CQL.html#batchStmt">BATCH</a></li></ol></li><li><a
href="CQL.html#queries">Queries</a><ol style="list-style: none;"><li><a
href="CQL.html#selectStmt">SELECT</a></li></ol></li><li><a
href="CQL.html#databaseUsers">Database Users</a><ol style="list-style:
none;"><li><a href="CQL.html#createUserStmt">CREATE USER </a></li><li><a
href="CQL.html#alterUserStmt">ALTER USER </a></li><li><a
href="CQL.html#dropUserStmt">DROP USER </a></li><li><a
href="CQL.html#listUsersStmt">LIST USERS</a></li></ol></li><li><a
href="CQL.html#dataControl">Data Control</a><ol style="list-style:
none;"><li><a href="CQL.html#permissions">Permissions </a></li><li><a hr
ef="CQL.html#grantPermissionsStmt">GRANT PERMISSION</a></li><li><a
href="CQL.html#revokePermissionsStmt">REVOKE
PERMISSION</a></li></ol></li><li><a href="CQL.html#types">Data Types</a><ol
style="list-style: none;"><li><a href="CQL.html#usingdates">Working with
dates</a></li><li><a href="CQL.html#counters">Counters</a></li><li><a
href="CQL.html#collections">Working with collections</a></li></ol></li><li><a
href="CQL.html#functions">Functions</a><ol style="list-style: none;"><li><a
href="CQL.html#tokenFun">Token</a></li><li><a
href="CQL.html#uuidFun">Uuid</a></li><li><a
href="CQL.html#timeuuidFun">Timeuuid functions</a></li><li><a
href="CQL.html#blobFun">Blob conversion functions</a></li></ol></li><li><a
href="CQL.html#appendixA">Appendix A: CQL Keywords</a></li><li><a
href="CQL.html#appendixB">Appendix B: CQL Reserved Types</a></li><li><a
href="CQL.html#changes">Changes</a><ol style="list-style: none;"><li><a
href="CQL.html#a3.2.0">3.2.0</a></li><li><a href="CQL.html#a3.1.7">3.1.7</a
></li><li><a href="CQL.html#a3.1.6">3.1.6</a></li><li><a
>href="CQL.html#a3.1.5">3.1.5</a></li><li><a
>href="CQL.html#a3.1.4">3.1.4</a></li><li><a
>href="CQL.html#a3.1.3">3.1.3</a></li><li><a
>href="CQL.html#a3.1.2">3.1.2</a></li><li><a
>href="CQL.html#a3.1.1">3.1.1</a></li><li><a
>href="CQL.html#a3.1.0">3.1.0</a></li><li><a
>href="CQL.html#a3.0.5">3.0.5</a></li><li><a
>href="CQL.html#a3.0.4">3.0.4</a></li><li><a
>href="CQL.html#a3.0.3">3.0.3</a></li><li><a
>href="CQL.html#a3.0.2">3.0.2</a></li><li><a
>href="CQL.html#a3.0.1">3.0.1</a></li></ol></li><li><a
>href="CQL.html#Versioning">Versioning</a></li></ol></li></ol></span><h2
>id="CQLSyntax">CQL Syntax</h2><h3 id="Preamble">Preamble</h3><p>This document
>describes the Cassandra Query Language (CQL) version 3. CQL v3 is not
>backward compatible with CQL v2 and differs from it in numerous ways. Note
>that this document describes the last version of the languages. However, the
><a href="#changes">changes</a> section provides the diff between the diffe
rent versions of CQL v3.</p><p>CQL v3 offers a model very close to SQL in the
sense that data is put in <em>tables</em> containing <em>rows</em> of
<em>columns</em>. For that reason, when used in this document, these terms
(tables, rows and columns) have the same definition than they have in SQL. But
please note that as such, they do <strong>not</strong> refer to the concept of
rows and columns found in the internal implementation of Cassandra and in the
thrift and CQL v2 API.</p><h3 id="Conventions">Conventions</h3><p>To aid in
specifying the CQL syntax, we will use the following conventions in this
document:</p><ul><li>Language rules will be given in a <a
href="http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form">BNF</a> -like
notation:</li></ul><pre class="syntax"><pre><start> ::= TERMINAL
<non-terminal1> <non-terminal1>
</pre></pre><ul><li>Nonterminal symbols will have <code><angle
brackets></code>.</li><li>As additional shortcut notations to BNF, we’ll
use traditional regular expression’s symbols (<code>?</code>,
<code>+</code> and <code>*</code>) to signify that a given symbol is optional
and/or can be repeated. We’ll also allow parentheses to group symbols and
the <code>[<characters>]</code> notation to represent any one of
<code><characters></code>.</li><li>The grammar is provided for documentation
purposes and leave some minor details out. For instance, the last column
definition in a <code>CREATE TABLE</code> statement is optional but supported
if present even though the provided grammar in this document suggest it is not
supported. </li><li>Sample code will be provided in a code block:</li></ul><pre
class="sample"><pre>SELECT sample_usage FROM cql;
</pre></pre><ul><li>References to keywords or pieces of CQL code in running
text will be shown in a <code>fixed-width font</code>.</li></ul><h3
id="identifiers">Identifiers and keywords</h3><p>The CQL language uses
<em>identifiers</em> (or <em>names</em>) to identify tables, columns and other
objects. An identifier is a token matching the regular expression <code
lang="a-zA-Z">[a-zA-Z0-9_]</code><code>*</code>.</p><p>A number of such
identifiers, like <code>SELECT</code> or <code>WITH</code>, are
<em>keywords</em>. They have a fixed meaning for the language and most are
reserved. The list of those keywords can be found in <a
href="#appendixA">Appendix A</a>.</p><p>Identifiers and (unquoted) keywords are
case insensitive. Thus <code>SELECT</code> is the same than <code>select</code>
or <code>sElEcT</code>, and <code>myId</code> is the same than
<code>myid</code> or <code>MYID</code> for instance. A convention often used
(in particular by the samples of this documentation) is to use u
pper case for keywords and lower case for other identifiers.</p><p>There is a
second kind of identifiers called <em>quoted identifiers</em> defined by
enclosing an arbitrary sequence of characters in double-quotes(<code>"</code>).
Quoted identifiers are never keywords. Thus <code>"select"</code> is not a
reserved keyword and can be used to refer to a column, while
<code>select</code> would raise a parse error. Also, contrarily to unquoted
identifiers and keywords, quoted identifiers are case sensitive (<code>"My
Quoted Id"</code> is <em>different</em> from <code>"my quoted id"</code>). A
fully lowercase quoted identifier that matches <code
lang="a-zA-Z">[a-zA-Z0-9_]</code><code>*</code> is equivalent to the unquoted
identifier obtained by removing the double-quote (so <code>"myid"</code> is
equivalent to <code>myid</code> and to <code>myId</code> but different from
<code>"myId"</code>). Inside a quoted identifier, the double-quote character
can be repeated to escape it, so <code>"fo
o "" bar"</code> is a valid identifier.</p><h3
id="constants">Constants</h3><p>CQL defines the following kind of
<em>constants</em>: strings, integers, floats, booleans, uuids and
blobs:</p><ul><li>A string constant is an arbitrary sequence of characters
characters enclosed by single-quote(<code>'</code>). One can include a
single-quote in a string by repeating it, e.g. <code>'It''s raining
today'</code>. Those are not to be confused with quoted identifiers that use
double-quotes.</li><li>An integer constant is defined by
<code>'-'?[0-9]+</code>.</li><li>A float constant is defined by
<code>'-'?[0-9]+('.'[0-9]*)?([eE][+-]?[0-9+])?</code>. On top of that,
<code>NaN</code> and <code>Infinity</code> are also float constants.</li><li>A
boolean constant is either <code>true</code> or <code>false</code> up to
case-insensitivity (i.e. <code>True</code> is a valid boolean
constant).</li><li>A <a
href="http://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a>
constant is defined b
y <code>hex{8}-hex{4}-hex{4}-hex{4}-hex{12}</code> where <code>hex</code> is
an hexadecimal character, e.g. <code>[0-9a-fA-F]</code> and <code>{4}</code> is
the number of such characters.</li><li>A blob constant is an hexadecimal number
defined by <code>0[xX](hex)+</code> where <code>hex</code> is an hexadecimal
character, e.g. <code>[0-9a-fA-F]</code>.</li></ul><p>For how these constants
are typed, see the <a href="#types">data types section</a>.</p><h3
id="Comments">Comments</h3><p>A comment in CQL is a line beginning by either
double dashes (<code>--</code>) or double slash
(<code>//</code>).</p><p>Multi-line comments are also supported through
enclosure within <code>/*</code> and <code>*/</code> (but nesting is not
supported).</p><pre class="sample"><pre>-- This is a comment
// This is a comment too
@@ -51,7 +51,7 @@ CREATE KEYSPACE Excalibur
</pre></pre><p><br/><i>Sample:</i></p><pre class="sample"><pre>ALTER KEYSPACE
Excelsior
WITH replication = {'class': 'SimpleStrategy', 'replication_factor'
: 4};
-</pre></pre><p><br/>The <code>ALTER KEYSPACE</code> statement alter the
properties of an existing keyspace. The supported <code><properties></code>
are the same that for the <a href="#createKeyspaceStmt"><code>CREATE
TABLE</code></a> statement.</p><h3 id="dropKeyspaceStmt">DROP
KEYSPACE</h3><p><i>Syntax:</i></p><pre
class="syntax"><pre><drop-keyspace-stmt> ::= DROP KEYSPACE ( IF EXISTS )?
<identifier>
+</pre></pre><p><br/>The <code>ALTER KEYSPACE</code> statement alters the
properties of an existing keyspace. The supported <code><properties></code>
are the same as for the <a href="#createKeyspaceStmt"><code>CREATE
KEYSPACE</code></a> statement.</p><h3 id="dropKeyspaceStmt">DROP
KEYSPACE</h3><p><i>Syntax:</i></p><pre
class="syntax"><pre><drop-keyspace-stmt> ::= DROP KEYSPACE ( IF EXISTS )?
<identifier>
</pre></pre><p><i>Sample:</i></p><pre class="sample"><pre>DROP KEYSPACE myApp;
</pre></pre><p>A <code>DROP KEYSPACE</code> statement results in the
immediate, irreversible removal of an existing keyspace, including all column
families in it, and all data contained in those column families.</p><p>If the
keyspace does not exists, the statement will return an error, unless <code>IF
EXISTS</code> is used in which case the operation is a no-op.</p><h3
id="createTableStmt">CREATE TABLE</h3><p><i>Syntax:</i></p><pre
class="syntax"><pre><create-table-stmt> ::= CREATE ( TABLE | COLUMNFAMILY )
( IF NOT EXISTS )? <tablename>
'(' <column-definition> ( ','
<column-definition> )* ')'
@@ -325,7 +325,56 @@ CREATE INDEX ON users(birth_year);
SELECT firstname, lastname FROM users WHERE birth_year = 1981;
</pre></pre><p>because in both case, Cassandra guarantees that these queries
performance will be proportional to the amount of data returned. In particular,
if no users are born in 1981, then the second query performance will not depend
of the number of user profile stored in the database (not directly at least:
due to secondary index implementation consideration, this query may still
depend on the number of node in the cluster, which indirectly depends on the
amount of data stored. Nevertheless, the number of nodes will always be
multiple number of magnitude lower than the number of user profile stored). Of
course, both query may return very large result set in practice, but the amount
of data returned can always be controlled by adding a
<code>LIMIT</code>.</p><p>However, the following query will be
rejected:</p><pre class="sample"><pre>SELECT firstname, lastname FROM users
WHERE birth_year = 1981 AND country = 'FR';
</pre></pre><p>because Cassandra cannot guarantee that it won’t have to
scan large amount of data even if the result to those query is small.
Typically, it will scan all the index entries for users born in 1981 even if
only a handful are actually from France. However, if you “know what you
are doing”, you can force the execution of this query by using
<code>ALLOW FILTERING</code> and so the following query is valid:</p><pre
class="sample"><pre>SELECT firstname, lastname FROM users WHERE birth_year =
1981 AND country = 'FR' ALLOW FILTERING;
-</pre></pre><h2 id="types">Data Types</h2><p>CQL supports a rich set of data
types for columns defined in a table, including collection types. On top of
those native and collection types, users can also provide custom types (through
a JAVA class extending <code>AbstractType</code> loadable by Cassandra). The
syntax of types is thus:</p><pre class="syntax"><pre><type> ::=
<native-type>
+</pre></pre><h2 id="databaseUsers">Database Users</h2><h3
id="createUserStmt">CREATE USER </h3><p><i>Syntax:</i> </p><pre
class="syntax"><pre><create-user-statement> ::= CREATE USER ( IF NOT EXISTS
)? <identifier> ( WITH PASSWORD <string> )? (<option>)?
+
+<option> ::= SUPERUSER
+ | NOSUPERUSER
+</pre></pre><p></p><p><i>Sample:</i> </p><pre class="sample"><pre>CREATE USER
alice WITH PASSWORD 'password_a' SUPERUSER;
+CREATE USER bob WITH PASSWORD 'password_b' NOSUPERUSER;
+</pre></pre><p>By default users do not possess <code>SUPERUSER</code>
status.</p><p><a href="#permissions">Permissions</a> on database resources
(keyspaces and tables) are granted to users.<br/>USer names should be quoted if
they contain non-alphanumeric characters. </p><h4 id="createUserPwd">Setting
credentials for internal authentication</h4><p>Use the <code>WITH
PASSWORD</code> clause to set a password for internal authentication, enclosing
the password in single quotation marks.<br/>If internal authentication has not
been set up the <code>WITH PASSWORD</code> clause is not necessary.</p><h4
id="createUserConditional">Creating a user conditionally</h4><p>Attempting to
create an existing user results in an invalid query condition unless the
<code>IF NOT EXISTS</code> option is used. If the option is used and the user
exists, the statement is a no-op.</p><pre class="sample"><pre>CREATE USER
carlos;
+CREATE USER IF NOT EXISTS carlos;
+</pre></pre><h3 id="alterUserStmt">ALTER USER </h3><p><i>Syntax:</i> </p><pre
class="syntax"><pre><alter-user-statement> ::= ALTER USER <identifier> (
WITH PASSWORD <string> )? ( <option> )?
+
+<option> ::= SUPERUSER
+ | NOSUPERUSER
+</pre></pre><p></p><pre class="sample"><pre>ALTER USER alice WITH PASSWORD
'PASSWORD_A';
+ALTER USER bob SUPERUSER;
+</pre></pre><p><code>ALTER USER</code> requires <code>SUPERUSER</code> status,
with two caveats:</p><ul><li>A user cannot alter its own <code>SUPERUSER</code>
status</li><li>A user without <code>SUPERUSER</code> status is permitted to
modify a subset of it’s own properties (e.g. its
<code>PASSWORD</code>)</li></ul><h3 id="dropUserStmt">DROP USER
</h3><p><i>Syntax:</i> </p><pre class="syntax"><pre><drop-user-stmt> ::=
DROP USER ( IF EXISTS )? <identifier>
+</pre></pre><p></p><p><i>Sample:</i> </p><pre class="sample"><pre>DROP USER
alice;
+DROP USER IF EXISTS bob;
+</pre></pre><p><code>DROP USER</code> requires <code>SUPERUSER</code> status,
and users are not permitted to <code>DROP</code> themselves.<br/>Attempting to
drop a user which does not exist results in an invalid query condition unless
the <code>IF EXISTS</code> option is used. If the option is used and the user
does not exist the statement is a no-op. </p><h3 id="listUsersStmt">LIST
USERS</h3><p><i>Syntax:</i></p><pre class="syntax"><pre><list-users-stmt>
::= LIST USERS;
+</pre></pre><p><i>Sample:</i></p><pre class="sample"><pre>LIST USERS;
+</pre></pre><p>Return all known users in the system.</p><h2
id="dataControl">Data Control</h2><h3 id="permissions">Permissions
</h3><p>Permissions on resources are granted to users and data resources in
Cassandra are organized hierarchically, like so: <code>ALL KEYSPACES</code> ->
<code>KEYSPACE</code> -> <code>TABLE</code></p><p>Permissions can be granted at
any level of the hierarchy and they flow downwards. So granting a permission on
a resource higher up the chain automatically grants that same permission on all
resources lower down. For example, granting <code>SELECT</code> on a
<code>KEYSPACE</code> automatically grants it on all <code>TABLES</code> in
that <code>KEYSPACE</code>. </p><p>Modifications to permissions are visible to
existing client sessions; that is, connections need not be re-established
following permissions changes.</p><p>The full set of available permissions
is:</p><ul><li><code>CREATE</code></li><li><code>ALTER</code></li><li><code>DROP</code></li><li><code>
SELECT</code></li><li><code>MODIFY</code></li><li><code>AUTHORIZE</code></li></ul><table><tr><th>permission
</th><th>resource </th><th>operations
</th></tr><tr><td><code>CREATE</code> </td><td><code>ALL KEYSPACES</code>
</td><td><code>CREATE KEYSPACE</code> <br> <code>CREATE TABLE</code>
in any keyspace</td></tr><tr><td><code>CREATE</code>
</td><td><code>KEYSPACE</code> </td><td><code>CREATE
TABLE</code> in specified keyspace</td></tr><tr><td><code>ALTER</code>
</td><td><code>ALL KEYSPACES</code> </td><td><code>ALTER
KEYSPACE</code> <br> <code>ALTER TABLE</code> in any
keyspace</td></tr><tr><td><code>ALTER</code>
</td><td><code>KEYSPACE</code> </td><td><code>ALTER
KEYSPACE</code> <br> <code>ALTER TABLE</code> in
keyspace</td></tr><tr><td><code>ALTER</code> </td><td><code>TABLE</code>
</td><td><code>ALTER
TABLE</code></td></tr><tr><td><code>DROP</code>
</td><td><code>ALL KEYSPACES</code> </td><td><code>DROP
KEYSPACE</code> <br> <code>DROP TABLE</code> in any
keyspace</td></tr><tr><td><code>DROP</code>
</td><td><code>KEYSPACE</code> </td><td><code>DROP
TABLE</code> in specified keyspace</td></tr><tr><td><code>DROP</code>
</td><td><code>TABLE</code> </td><td><code>DROP
TABLE</code></td></tr><tr><td><code>SELECT</code> </td><td><code>ALL
KEYSPACES</code> </td><td><code>SELECT</code> on any
table</td></tr><tr><td><code>SELECT</code> </td><td><code>KEYSPACE</code>
</td><td><code>SELECT</code> on any table in
keyspace</td></tr><tr><td><code>SELECT</code> </td><td><code>TABLE</code>
</td><td><code>SELECT</code> on specified
table</td></tr><tr><td><code>MODIFY</code> </td><td><code>ALL
KEYSPACES</code> </td><td><code>INSERT</code> on any table <br>
<code>UPDATE</code> on any table <br> <code>
DELETE</code> on any table <br> <code>TRUNCATE</code> on any
table</td></tr><tr><td><code>MODIFY</code> </td><td><code>KEYSPACE</code>
</td><td><code>INSERT</code> on any table in keyspace <br>
<code>UPDATE</code> on any table in keyspace <br> <code>DELETE</code> on any
table in keyspace <br> <code>TRUNCATE</code> on any table in
keyspace</td></tr><tr><td><code>MODIFY</code> </td><td><code>TABLE</code>
</td><td><code>INSERT</code> <br> <code>UPDATE</code> <br>
<code>DELETE</code> <br>
<code>TRUNCATE</code></td></tr><tr><td><code>AUTHORIZE</code>
</td><td><code>ALL KEYSPACES</code> </td><td><code>GRANT
PERMISSION</code> on any table <br> <code>REVOKE PERMISSION</code> on any
table</td></tr><tr><td><code>AUTHORIZE</code> </td><td><code>KEYSPACE</code>
</td><td><code>GRANT PERMISSION</code> on table in keyspace
<br> <code>REVOKE PERMISSION</code> on table in
keyspace</td></tr><tr><td><code>AUTHORIZE</code>
</td><td><code>TABLE</code> </td><td><code>GRANT
PERMISSION</code> <br> <code>REVOKE PERMISSION</code> </td></tr></table><h3
id="grantPermissionsStmt">GRANT PERMISSION</h3><p><i>Syntax:</i> </p><pre
class="syntax"><pre><grant-permission-stmt> ::= GRANT ( ALL ( PERMISSIONS )?
| <permission> ( PERMISSION )? ) ON <resource> TO <identifier>
+
+<permission> ::= CREATE | ALTER | DROP | SELECT | MODIFY | AUTHORIZE
+
+<resource> ::= ALL KEYSPACES
+ | KEYSPACE <identifier>
+ | ( TABLE )? <tablename>
+</pre></pre><p></p><p><i>Sample:</i> </p><pre class="sample"><pre>GRANT SELECT
ON ALL KEYSPACES TO alice;
+</pre></pre><p>This gives <code>alice</code> permissions to execute
<code>SELECT</code> statements on any table across all keyspaces</p><pre
class="sample"><pre>GRANT MODIFY ON KEYSPACE keyspace1 TO bob;
+</pre></pre><p>This gives <code>bob</code> permissions to perform
<code>UPDATE</code>, <code>INSERT</code>, <code>UPDATE</code>,
<code>DELETE</code> and <code>TRUNCATE</code> queries on all tables in the
<code>keyspace1</code> keyspace</p><pre class="sample"><pre>GRANT DROP ON
keyspace1.table1 TO carlos;
+</pre></pre><p>This gives <code>carlos</code> permissions to <code>DROP</code>
<code>keyspace1.table1</code>.</p><h3 id="revokePermissionsStmt">REVOKE
PERMISSION</h3><p><i>Syntax:</i> </p><pre
class="syntax"><pre><revoke-permission-stmt> ::= REVOKE ( ALL ( PERMISSIONS
)? | <permission> ( PERMISSION )? ) ON <resource> FROM <identifier>
+
+<permission> ::= CREATE | ALTER | DROP | SELECT | MODIFY | AUTHORIZE
+
+<resource> ::= ALL KEYSPACES
+ | KEYSPACE <identifier>
+ | ( TABLE )? <tablename>
+</pre></pre><p></p><p><i>Sample:</i> </p><pre class="sample"><pre>REVOKE
SELECT ON ALL KEYSPACES FROM alice;
+REVOKE MODIFY ON KEYSPACE keyspace1 FROM bob;
+REVOKE DROP ON keyspace1.table1 FROM carlos;
+</pre></pre><p></p><h4 id="listPermissionsStmt">LIST
PERMISSIONS</h4><p><i>Syntax:</i></p><pre
class="syntax"><pre><list-permissions-stmt> ::= LIST ( ALL ( PERMISSIONS )?
| <permission> )
+ ( ON <resource> )?
+ ( OF <identifier> ( NORECURSIVE )? )?
+
+<resource> ::= ALL KEYSPACES
+ | KEYSPACE <identifier>
+ | ( TABLE )? <tablename>
+</pre></pre><p></p><p><i>Sample:</i></p><pre class="sample"><pre>LIST ALL
PERMISSIONS OF alice;
+</pre></pre><p>Show all permissions granted to <code>alice</code>. </p><pre
class="sample"><pre>LIST ALL PERMISSIONS ON keyspace1.table1 OF bob;
+</pre></pre><p>Show all permissions on <code>keyspace1.table1</code> granted
to <code>bob</code>. This also includes any permissions higher up the resource
hierarchy which can be applied to <code>keyspace1.table1</code>. For example,
should <code>bob</code> have <code>ALTER</code> permission on
<code>keyspace1</code>, that would be included in the results of this query.
Adding the <code>NORECURSIVE</code> switch restricts the results to only those
permissions which were directly granted to <code>bob</code>.</p><pre
class="sample"><pre>LIST SELECT PERMISSIONS OF carlos;
+</pre></pre><p>Show any permissions granted to <code>carlos</code>, limited to
<code>SELECT</code> permissions on any resource.</p><h2 id="types">Data
Types</h2><p>CQL supports a rich set of data types for columns defined in a
table, including collection types. On top of those native and collection types,
users can also provide custom types (through a JAVA class extending
<code>AbstractType</code> loadable by Cassandra). The syntax of types is
thus:</p><pre class="syntax"><pre><type> ::= <native-type>
| <collection-type>
| <tuple-type>
| <string> // Used for custom types. The fully-qualified
name of a JAVA class