Author: blerer
Date: Thu Jan 21 11:14:39 2016
New Revision: 1725905
URL: http://svn.apache.org/viewvc?rev=1725905&view=rev
Log:
Update to the latest version
Modified:
cassandra/site/publish/doc/cql3/CQL-3.0.html
Modified: cassandra/site/publish/doc/cql3/CQL-3.0.html
URL:
http://svn.apache.org/viewvc/cassandra/site/publish/doc/cql3/CQL-3.0.html?rev=1725905&r1=1725904&r2=1725905&view=diff
==============================================================================
--- cassandra/site/publish/doc/cql3/CQL-3.0.html (original)
+++ cassandra/site/publish/doc/cql3/CQL-3.0.html Thu Jan 21 11:14:39 2016
@@ -1,6 +1,6 @@
-<?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.4.0">Cassandra Query Language (CQL)
v3.4.0</h1><span id="tableOfContents"><ol style="list-style: none;"><li><a
href="CQL.html#CassandraQueryLanguageCQLv3.4.0">Cassandra Query Language (CQL)
v3.4.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#createMVStmt">CREATE MATERIALIZED VIEW</a></li><li><a
href="CQL.html#alterMVStmt">ALTER MATERIALIZED VIEW</a></li><li><a
href="CQL.html#dropMVStmt">DROP MATERIALIZED VIEW</a></l
i><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#createTriggerStmt">CREATE TRIGGER</a></li><li><a
href="CQL.html#dropTriggerStmt">DROP TRIGGER</a></li><li><a
href="CQL.html#createFunctionStmt">CREATE FUNCTION</a></li><li><a
href="CQL.html#dropFunctionStmt">DROP FUNCTION</a></li><li><a
href="CQL.html#createAggregateStmt">CREATE AGGREGATE</a></li><li><a
href="CQL.html#dropAggregateStmt">DROP AGGREGATE</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#databaseRoles">Database Roles</a><ol style="list-style:
none;"><li><a href="CQL.html#createRoleStmt">CREATE ROLE</a></li><li><a
href="CQL.html#alterRoleStmt">ALTER ROLE</a></li><li><a
href="CQL.html#dropRoleStmt">DROP ROLE</a></li><li><a
href="CQL.html#grantRoleStmt">GRANT ROLE</a></li><li><a
href="CQL.html#revokeRoleStmt">REVOKE ROLE</a></li><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
href="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#usingtimestamps">W
orking with timestamps</a></li><li><a href="CQL.html#usingdates">Working with
dates</a></li><li><a href="CQL.html#usingtime">Working with time</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#timeFun">Time conversion functions</a></li><li><a
href="CQL.html#blobFun">Blob conversion functions</a></li></ol></li><li><a
href="CQL.html#aggregates">Aggregates</a><ol style="list-style: none;"><li><a
href="CQL.html#countFct">Count</a></li><li><a href="CQL.html#maxMinFcts">Max
and Min</a></li><li><a href="CQL.html#sumFct">Sum</a></li><li><a
href="CQL.html#avgFct">Avg</a></li></ol></li><li><a
href="CQL.html#udfs">User-Defined Functions</a></li><li><a href="CQL.htm
l#udas">User-Defined Aggregates</a></li><li><a href="CQL.html#json">JSON
Support</a><ol style="list-style: none;"><li><a
href="CQL.html#selectJson">SELECT JSON</a></li><li><a
href="CQL.html#insertJson">INSERT JSON</a></li><li><a
href="CQL.html#jsonEncoding">JSON Encoding of Cassandra Data
Types</a></li><li><a href="CQL.html#fromJson">The fromJson()
Function</a></li><li><a href="CQL.html#toJson">The toJson()
Function</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.4.0">3.4.0</a></li><li><a
href="CQL.html#a3.3.1">3.3.1</a></li><li><a
href="CQL.html#a3.3.0">3.3.0</a></li><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
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>
+<?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-3.0</title></head><body><p><link
rel="StyleSheet" href="CQL.css" type="text/css" media="screen"></p><h1
id="CassandraQueryLanguageCQLv3.4.0">Cassandra Query Language (CQL)
v3.4.0</h1><span id="tableOfContents"><ol style="list-style: none;"><li><a
href="CQL-3.0.html#CassandraQueryLanguageCQLv3.4.0">Cassandra Query Language
(CQL) v3.4.0</a><ol style="list-style: none;"><li><a
href="CQL-3.0.html#CQLSyntax">CQL Syntax</a><ol style="list-style:
none;"><li><a href="CQL-3.0.html#Preamble">Preamble</a></li><li><a
href="CQL-3.0.html#Conventions">Conventions</a></li><li><a
href="CQL-3.0.html#identifiers">Identifiers and keywords</a></li><li><a
href="CQL-3.0.html#constants">Constants</a></li><li><a href="CQL-3.
0.html#Comments">Comments</a></li><li><a
href="CQL-3.0.html#statements">Statements</a></li><li><a
href="CQL-3.0.html#preparedStatement">Prepared
Statement</a></li></ol></li><li><a href="CQL-3.0.html#dataDefinition">Data
Definition</a><ol style="list-style: none;"><li><a
href="CQL-3.0.html#createKeyspaceStmt">CREATE KEYSPACE</a></li><li><a
href="CQL-3.0.html#useStmt">USE</a></li><li><a
href="CQL-3.0.html#alterKeyspaceStmt">ALTER KEYSPACE</a></li><li><a
href="CQL-3.0.html#dropKeyspaceStmt">DROP KEYSPACE</a></li><li><a
href="CQL-3.0.html#createTableStmt">CREATE TABLE</a></li><li><a
href="CQL-3.0.html#alterTableStmt">ALTER TABLE</a></li><li><a
href="CQL-3.0.html#dropTableStmt">DROP TABLE</a></li><li><a
href="CQL-3.0.html#truncateStmt">TRUNCATE</a></li><li><a
href="CQL-3.0.html#createIndexStmt">CREATE INDEX</a></li><li><a
href="CQL-3.0.html#dropIndexStmt">DROP INDEX</a></li><li><a
href="CQL-3.0.html#createMVStmt">CREATE MATERIALIZED VIEW</a></li><li><a
href="CQL-3.0.html#alterMVStmt">ALT
ER MATERIALIZED VIEW</a></li><li><a href="CQL-3.0.html#dropMVStmt">DROP
MATERIALIZED VIEW</a></li><li><a href="CQL-3.0.html#createTypeStmt">CREATE
TYPE</a></li><li><a href="CQL-3.0.html#alterTypeStmt">ALTER TYPE</a></li><li><a
href="CQL-3.0.html#dropTypeStmt">DROP TYPE</a></li><li><a
href="CQL-3.0.html#createTriggerStmt">CREATE TRIGGER</a></li><li><a
href="CQL-3.0.html#dropTriggerStmt">DROP TRIGGER</a></li><li><a
href="CQL-3.0.html#createFunctionStmt">CREATE FUNCTION</a></li><li><a
href="CQL-3.0.html#dropFunctionStmt">DROP FUNCTION</a></li><li><a
href="CQL-3.0.html#createAggregateStmt">CREATE AGGREGATE</a></li><li><a
href="CQL-3.0.html#dropAggregateStmt">DROP AGGREGATE</a></li></ol></li><li><a
href="CQL-3.0.html#dataManipulation">Data Manipulation</a><ol
style="list-style: none;"><li><a
href="CQL-3.0.html#insertStmt">INSERT</a></li><li><a
href="CQL-3.0.html#updateStmt">UPDATE</a></li><li><a
href="CQL-3.0.html#deleteStmt">DELETE</a></li><li><a
href="CQL-3.0.html#batchStmt">BATCH</a><
/li></ol></li><li><a href="CQL-3.0.html#queries">Queries</a><ol
style="list-style: none;"><li><a
href="CQL-3.0.html#selectStmt">SELECT</a></li></ol></li><li><a
href="CQL-3.0.html#databaseRoles">Database Roles</a><ol style="list-style:
none;"><li><a href="CQL-3.0.html#createRoleStmt">CREATE ROLE</a></li><li><a
href="CQL-3.0.html#alterRoleStmt">ALTER ROLE</a></li><li><a
href="CQL-3.0.html#dropRoleStmt">DROP ROLE</a></li><li><a
href="CQL-3.0.html#grantRoleStmt">GRANT ROLE</a></li><li><a
href="CQL-3.0.html#revokeRoleStmt">REVOKE ROLE</a></li><li><a
href="CQL-3.0.html#createUserStmt">CREATE USER </a></li><li><a
href="CQL-3.0.html#alterUserStmt">ALTER USER </a></li><li><a
href="CQL-3.0.html#dropUserStmt">DROP USER </a></li><li><a
href="CQL-3.0.html#listUsersStmt">LIST USERS</a></li></ol></li><li><a
href="CQL-3.0.html#dataControl">Data Control</a><ol style="list-style:
none;"><li><a href="CQL-3.0.html#permissions">Permissions </a></li><li><a
href="CQL-3.0.html#grantPermissionsStmt">GRANT P
ERMISSION</a></li><li><a href="CQL-3.0.html#revokePermissionsStmt">REVOKE
PERMISSION</a></li></ol></li><li><a href="CQL-3.0.html#types">Data Types</a><ol
style="list-style: none;"><li><a href="CQL-3.0.html#usingtimestamps">Working
with timestamps</a></li><li><a href="CQL-3.0.html#usingdates">Working with
dates</a></li><li><a href="CQL-3.0.html#usingtime">Working with
time</a></li><li><a href="CQL-3.0.html#counters">Counters</a></li><li><a
href="CQL-3.0.html#collections">Working with
collections</a></li></ol></li><li><a
href="CQL-3.0.html#functions">Functions</a><ol style="list-style: none;"><li><a
href="CQL-3.0.html#tokenFun">Token</a></li><li><a
href="CQL-3.0.html#uuidFun">Uuid</a></li><li><a
href="CQL-3.0.html#timeuuidFun">Timeuuid functions</a></li><li><a
href="CQL-3.0.html#timeFun">Time conversion functions</a></li><li><a
href="CQL-3.0.html#blobFun">Blob conversion functions</a></li></ol></li><li><a
href="CQL-3.0.html#aggregates">Aggregates</a><ol style="list-style: none;"><li><
a href="CQL-3.0.html#countFct">Count</a></li><li><a
href="CQL-3.0.html#maxMinFcts">Max and Min</a></li><li><a
href="CQL-3.0.html#sumFct">Sum</a></li><li><a
href="CQL-3.0.html#avgFct">Avg</a></li></ol></li><li><a
href="CQL-3.0.html#udfs">User-Defined Functions</a></li><li><a
href="CQL-3.0.html#udas">User-Defined Aggregates</a></li><li><a
href="CQL-3.0.html#json">JSON Support</a><ol style="list-style: none;"><li><a
href="CQL-3.0.html#selectJson">SELECT JSON</a></li><li><a
href="CQL-3.0.html#insertJson">INSERT JSON</a></li><li><a
href="CQL-3.0.html#jsonEncoding">JSON Encoding of Cassandra Data
Types</a></li><li><a href="CQL-3.0.html#fromJson">The fromJson()
Function</a></li><li><a href="CQL-3.0.html#toJson">The toJson()
Function</a></li></ol></li><li><a href="CQL-3.0.html#appendixA">Appendix A: CQL
Keywords</a></li><li><a href="CQL-3.0.html#appendixB">Appendix B: CQL Reserved
Types</a></li><li><a href="CQL-3.0.html#changes">Changes</a><ol
style="list-style: none;"><li><a href="CQL-3.0.
html#a3.4.0">3.4.0</a></li><li><a
href="CQL-3.0.html#a3.3.1">3.3.1</a></li><li><a
href="CQL-3.0.html#a3.3.0">3.3.0</a></li><li><a
href="CQL-3.0.html#a3.2.0">3.2.0</a></li><li><a
href="CQL-3.0.html#a3.1.7">3.1.7</a></li><li><a
href="CQL-3.0.html#a3.1.6">3.1.6</a></li><li><a
href="CQL-3.0.html#a3.1.5">3.1.5</a></li><li><a
href="CQL-3.0.html#a3.1.4">3.1.4</a></li><li><a
href="CQL-3.0.html#a3.1.3">3.1.3</a></li><li><a
href="CQL-3.0.html#a3.1.2">3.1.2</a></li><li><a
href="CQL-3.0.html#a3.1.1">3.1.1</a></li><li><a
href="CQL-3.0.html#a3.1.0">3.1.0</a></li><li><a
href="CQL-3.0.html#a3.0.5">3.0.5</a></li><li><a
href="CQL-3.0.html#a3.0.4">3.0.4</a></li><li><a
href="CQL-3.0.html#a3.0.3">3.0.3</a></li><li><a
href="CQL-3.0.html#a3.0.2">3.0.2</a></li><li><a
href="CQL-3.0.html#a3.0.1">3.0.1</a></li></ol></li><li><a
href="CQL-3.0.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 L
anguage (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 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>[a-zA-Z]</code><code>[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 t
o use upper 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>[a-zA-Z]</code><code>[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>"foo "" 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>
constan
t is defined by <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
+</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>[a-zA-Z]</code><code>[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 t
o use upper 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>[a-zA-Z]</code><code>[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>"foo "" bar"</code> is a valid
identifier.</p><p><strong>Warning</strong>: <em>quoted identifiers</em> allows
to declare columns with arbitrary names, and those can sometime clash with
specific names used by the server. For instance, when using conditional update,
the server will respond with a result-set containing a special result named
<code>"[applied]"</code>. If you’ve declared a column with such a name,
this could potentially confuse some tools and should be avoided. In general,
unquoted identifiers should be preferred but if you use quoted identifiers, it
is strongly advised to avoid any name enclosed by squared brackets (like
<code>"[applied]"</code>) and any name that looks like a function call (like
<code>"f(x)"</code>).</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 s
ingle-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 by <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
/* This is
a multi-line comment */
@@ -94,7 +94,7 @@ CREATE TABLE timeline (
other text,
PRIMARY KEY (k)
)
-</pre></pre><h4 id="createTablepartitionClustering">Partition key and
clustering columns</h4><p>In CQL, the order in which columns are defined for
the <code>PRIMARY KEY</code> matters. The first column of the key is called the
<i>partition key</i>. It has the property that all the rows sharing the same
partition key (even across table in fact) are stored on the same physical node.
Also, insertion/update/deletion on rows sharing the same partition key for a
given table are performed <i>atomically</i> and in <i>isolation</i>. Note that
it is possible to have a composite partition key, i.e. a partition key formed
of multiple columns, using an extra set of parentheses to define which columns
forms the partition key.</p><p>The remaining columns of the <code>PRIMARY
KEY</code> definition, if any, are called __clustering columns. On a given
physical node, rows for a given partition key are stored in the order induced
by the clustering columns, making the retrieval of rows in that clusterin
g order particularly efficient (see <a
href="#selectStmt"><tt>SELECT</tt></a>).</p><h4
id="createTableStatic"><code>STATIC</code> columns</h4><p>Some columns can be
declared as <code>STATIC</code> in a table definition. A column that is static
will be “shared” by all the rows belonging to the same partition
(having the same partition key). For instance, in:</p><pre
class="sample"><pre>CREATE TABLE test (
+</pre></pre><h4 id="createTablepartitionClustering">Partition key and
clustering columns</h4><p>In CQL, the order in which columns are defined for
the <code>PRIMARY KEY</code> matters. The first column of the key is called the
<i>partition key</i>. It has the property that all the rows sharing the same
partition key (even across table in fact) are stored on the same physical node.
Also, insertion/update/deletion on rows sharing the same partition key for a
given table are performed <i>atomically</i> and in <i>isolation</i>. Note that
it is possible to have a composite partition key, i.e. a partition key formed
of multiple columns, using an extra set of parentheses to define which columns
forms the partition key.</p><p>The remaining columns of the <code>PRIMARY
KEY</code> definition, if any, are called __clustering columns. On a given
physical node, rows for a given partition key are stored in the order induced
by the clustering columns, making the retrieval of rows in that clusterin
g order particularly efficient (see <a
href="#selectStmt"><tt>SELECT</tt></a>).</p><h4
id="createTableStatic"><code>STATIC</code> columns</h4><p>Some columns can be
declared as <code>STATIC</code> in a table definition. A column that is static
will be «shared» by all the rows belonging to the same partition
(having the same partition key). For instance, in:</p><pre
class="sample"><pre>CREATE TABLE test (
pk int,
t int,
v text,
@@ -104,7 +104,7 @@ CREATE TABLE timeline (
INSERT INTO test(pk, t, v, s) VALUES (0, 0, 'val0', 'static0');
INSERT INTO test(pk, t, v, s) VALUES (0, 1, 'val1', 'static1');
SELECT * FROM test WHERE pk=0 AND t=0;
-</pre></pre><p>the last query will return <code>'static1'</code> as value for
<code>s</code>, since <code>s</code> is static and thus the 2nd insertion
modified this “shared” value. Note however that static columns are
only static within a given partition, and if in the example above both rows
where from different partitions (i.e. if they had different value for
<code>pk</code>), then the 2nd insertion would not have modified the value of
<code>s</code> for the first row.</p><p>A few restrictions applies to when
static columns are allowed:</p><ul><li>tables with the <code>COMPACT
STORAGE</code> option (see below) cannot have them</li><li>a table without
clustering columns cannot have static columns (in a table without clustering
columns, every partition has only one row, and so every column is inherently
static).</li><li>only non <code>PRIMARY KEY</code> columns can be
static</li></ul><h4 id="createTableOptions"><code><option></code></h4><p>The
<code>CREATE TABLE</cod
e> statement supports a number of options that controls the configuration of a
new table. These options can be specified after the <code>WITH</code>
keyword.</p><p>The first of these option is <code>COMPACT STORAGE</code>. This
option is mainly targeted towards backward compatibility for definitions
created before CQL3 (see <a
href="http://www.datastax.com/dev/blog/thrift-to-cql3">www.datastax.com/dev/blog/thrift-to-cql3</a>
for more details). The option also provides a slightly more compact layout of
data on disk but at the price of diminished flexibility and extensibility for
the table. Most notably, <code>COMPACT STORAGE</code> tables cannot have
collections nor static columns and a <code>COMPACT STORAGE</code> table with at
least one clustering column supports exactly one (as in not 0 nor more than 1)
column not part of the <code>PRIMARY KEY</code> definition (which imply in
particular that you cannot add nor remove columns after creation). For those
reasons, <code>COMPACT STO
RAGE</code> is not recommended outside of the backward compatibility reason
evoked above.</p><p>Another option is <code>CLUSTERING ORDER</code>. It allows
to define the ordering of rows on disk. It takes the list of the clustering
column names with, for each of them, the on-disk order (Ascending or
descending). Note that this option affects <a href="#selectOrderBy">what
<code>ORDER BY</code> are allowed during <code>SELECT</code></a>.</p><p>Table
creation supports the following other
<code><property></code>:</p><table><tr><th>option
</th><th>kind </th><th>default
</th><th>description</th></tr><tr><td><code>comment</code>
</td><td><em>simple</em> </td><td>none </td><td>A free-form,
human-readable comment.</td></tr><tr><td><code>read_repair_chance</code>
</td><td><em>simple</em> </td><td>0.1 </td><td>The probability with
which to query extra nodes (e.g. more nodes than required by the consistency
level) for the purpos
e of read repairs.</td></tr><tr><td><code>dclocal_read_repair_chance</code>
</td><td><em>simple</em> </td><td>0 </td><td>The probability with
which to query extra nodes (e.g. more nodes than required by the consistency
level) belonging to the same data center than the read coordinator for the
purpose of read repairs.</td></tr><tr><td><code>gc_grace_seconds</code>
</td><td><em>simple</em> </td><td>864000 </td><td>Time to wait before
garbage collecting tombstones (deletion
markers).</td></tr><tr><td><code>bloom_filter_fp_chance</code>
</td><td><em>simple</em> </td><td>0.00075 </td><td>The target probability
of false positive of the sstable bloom filters. Said bloom filters will be
sized to provide the provided probability (thus lowering this value impact the
size of bloom filters in-memory and
on-disk)</td></tr><tr><td><code>default_time_to_live</code>
</td><td><em>simple</em> </td><td>0 </td><td>The default expiration
time (“TTL&
#8221;) in seconds for a table.</td></tr><tr><td><code>compaction</code>
</td><td><em>map</em> </td><td><em>see below</em>
</td><td>Compaction options, see <a
href="#compactionOptions">below</a>.</td></tr><tr><td><code>compression</code>
</td><td><em>map</em> </td><td><em>see below</em>
</td><td>Compression options, see <a
href="#compressionOptions">below</a>.</td></tr><tr><td><code>caching</code>
</td><td><em>map</em> </td><td><em>see below</em>
</td><td>Caching options, see <a
href="#cachingOptions">below</a>.</td></tr></table><h4
id="compactionOptions">Compaction options</h4><p>The <code>compaction</code>
property must at least define the <code>'class'</code> sub-option, that defines
the compaction strategy class to use. The default supported class are
<code>'SizeTieredCompactionStrategy'</code>,
<code>'LeveledCompactionStrategy'</code> and
<code>'DateTieredCompactionStrategy'</code>. Custom strategy can be provided by
sp
ecifying the full class name as a <a href="#constants">string constant</a>.
The rest of the sub-options depends on the chosen class. The sub-options
supported by the default classes are:</p><table><tr><th>option
</th><th>supported compaction strategy </th><th>default
</th><th>description </th></tr><tr><td><code>enabled</code>
</td><td><em>all</em> </td><td>true
</td><td>A boolean denoting whether compaction should be enabled or
not.</td></tr><tr><td><code>tombstone_threshold</code>
</td><td><em>all</em> </td><td>0.2
</td><td>A ratio such that if a sstable has more than this ratio of gcable
tombstones over all contained columns, the sstable will be compacted (with no
other sstables) for the purpose of purging those tombstones.
</td></tr><tr><td><code>tombstone_compaction_interval</code>
</td><td><em>all</em> </td><td>1 day
</td><td>The minimum time to wait after an sstable creation time before
considering it for “tombstone compaction”, where “tombstone
compaction” is the compaction triggered if the sstable has more gcable
tombstones than <code>tombstone_threshold</code>.
</td></tr><tr><td><code>unchecked_tombstone_compaction</code>
</td><td><em>all</em> </td><td>false
</td><td>Setting this to true enables more aggressive tombstone compactions
– single sstable tombstone compactions will run without checking how
likely it is that they will be successful.
</td></tr><tr><td><code>min_sstable_size</code>
</td><td>SizeTieredCompactionStrategy </td><td>50MB </td><td>The
size tiered strategy groups SSTables to compact in buckets. A bucket groups
SSTables that differs from less than 50% in size. However, for small sizes,
this would result in a bucketing that is too fine grained.
<code>min_sstable_size</code> defines a siz
e threshold (in bytes) below which all SSTables belong to one unique
bucket</td></tr><tr><td><code>min_threshold</code>
</td><td>SizeTieredCompactionStrategy </td><td>4 </td><td>Minimum
number of SSTables needed to start a minor
compaction.</td></tr><tr><td><code>max_threshold</code>
</td><td>SizeTieredCompactionStrategy </td><td>32 </td><td>Maximum
number of SSTables processed by one minor
compaction.</td></tr><tr><td><code>bucket_low</code>
</td><td>SizeTieredCompactionStrategy </td><td>0.5 </td><td>Size
tiered consider sstables to be within the same bucket if their size is within
[average_size * <code>bucket_low</code>, average_size *
<code>bucket_high</code> ] (i.e the default groups sstable whose sizes diverges
by at most 50%)</td></tr><tr><td><code>bucket_high</code>
</td><td>SizeTieredCompactionStrategy </td><td>1.5 </td><td>Size
tiered consider sstables
to be within the same bucket if their size is within [average_size *
<code>bucket_low</code>, average_size * <code>bucket_high</code> ] (i.e the
default groups sstable whose sizes diverges by at most
50%).</td></tr><tr><td><code>sstable_size_in_mb</code>
</td><td>LeveledCompactionStrategy </td><td>5MB </td><td>The
target size (in MB) for sstables in the leveled strategy. Note that while
sstable sizes should stay less or equal to <code>sstable_size_in_mb</code>, it
is possible to exceptionally have a larger sstable as during compaction, data
for a given partition key are never split into 2
sstables</td></tr><tr><td><code>timestamp_resolution</code>
</td><td>DateTieredCompactionStrategy </td><td>MICROSECONDS </td><td>The
timestamp resolution used when inserting data, could be MILLISECONDS,
MICROSECONDS etc (should be understandable by Java
TimeUnit)</td></tr><tr><td><code>base_time_seconds</code>
</td><td>DateTieredCompactionStrate
gy </td><td>60 </td><td>The base size of the time windows.
</td></tr><tr><td><code>max_sstable_age_days</code>
</td><td>DateTieredCompactionStrategy </td><td>365
</td><td>SSTables only containing data that is older than this will never be
compacted. </td></tr></table><h4 id="compressionOptions">Compression
options</h4><p>For the <code>compression</code> property, the following
sub-options are available:</p><table><tr><th>option
</th><th>default </th><th>description
</th></tr><tr><td><code>class</code> </td><td>LZ4Compressor
</td><td>The compression algorithm to use. Default compressor are:
LZ4Compressor, SnappyCompressor and DeflateCompressor. Use <code>'enabled' :
false</code> to disable compression. Custom compressor can be provided by
specifying the full class name as a <a href="#constants">string
constant</a>.</td></tr><tr><td><code>enabled</code>
</td><td>true </td><td>By de
fault compression is enabled. To disable it, set <code>enabled</code> to
<code>false</code></td></tr><tr><td><code>chunk_length_in_kb</code>
</td><td>64KB </td><td>On disk SSTables are compressed by block (to
allow random reads). This defines the size (in KB) of said block. Bigger values
may improve the compression rate, but increases the minimum size of data to be
read from disk for a read </td></tr><tr><td><code>crc_check_chance</code>
</td><td>1.0 </td><td>When compression is enabled, each compressed
block includes a checksum of that block for the purpose of detecting disk
bitrot and avoiding the propagation of corruption to other replica. This option
defines the probability with which those checksums are checked during read. By
default they are always checked. Set to 0 to disable checksum checking and to
0.5 for instance to check them every other read</td></tr></table><h4
id="cachingOptions">Caching options</h4><p>For the <code>caching</code> p
roperty, the following sub-options are available:</p><table><tr><th>option
</th><th>default </th><th>description
</th></tr><tr><td><code>keys</code> </td><td>ALL
</td><td>Whether to cache keys (“key cache”) for this table. Valid
values are: <code>ALL</code> and
<code>NONE</code>.</td></tr><tr><td><code>rows_per_partition</code>
</td><td>NONE </td><td>The amount of rows to cache per partition (“row
cache”). If an integer <code>n</code> is specified, the first
<code>n</code> queried rows of a partition will be cached. Other possible
options are <code>ALL</code>, to cache all rows of a queried partition, or
<code>NONE</code> to disable row caching.</td></tr></table><h4
id="Otherconsiderations">Other considerations:</h4><ul><li>When <a
href="#insertStmt">inserting</a> / <a href="#updateStmt">updating</a> a given
row, not all columns needs to be defined (except for those part of the key),
and missing columns occupy no spac
e on disk. Furthermore, adding new columns (see <a
href=#alterStmt><tt>ALTER TABLE</tt></a>) is a constant time operation. There
is thus no need to try to anticipate future usage (or to cry when you
haven’t) when creating a table.</li></ul><h3 id="alterTableStmt">ALTER
TABLE</h3><p><i>Syntax:</i></p><pre class="syntax"><pre><alter-table-stmt>
::= ALTER (TABLE | COLUMNFAMILY) <tablename> <instruction>
+</pre></pre><p>the last query will return <code>'static1'</code> as value for
<code>s</code>, since <code>s</code> is static and thus the 2nd insertion
modified this «shared» value. Note however that static columns are
only static within a given partition, and if in the example above both rows
where from different partitions (i.e. if they had different value for
<code>pk</code>), then the 2nd insertion would not have modified the value of
<code>s</code> for the first row.</p><p>A few restrictions applies to when
static columns are allowed:</p><ul><li>tables with the <code>COMPACT
STORAGE</code> option (see below) cannot have them</li><li>a table without
clustering columns cannot have static columns (in a table without clustering
columns, every partition has only one row, and so every column is inherently
static).</li><li>only non <code>PRIMARY KEY</code> columns can be
static</li></ul><h4 id="createTableOptions"><code><option></code></h4><p>The
<code>CREATE TABLE</code>
statement supports a number of options that controls the configuration of a
new table. These options can be specified after the <code>WITH</code>
keyword.</p><p>The first of these option is <code>COMPACT STORAGE</code>. This
option is mainly targeted towards backward compatibility for definitions
created before CQL3 (see <a
href="http://www.datastax.com/dev/blog/thrift-to-cql3">www.datastax.com/dev/blog/thrift-to-cql3</a>
for more details). The option also provides a slightly more compact layout of
data on disk but at the price of diminished flexibility and extensibility for
the table. Most notably, <code>COMPACT STORAGE</code> tables cannot have
collections nor static columns and a <code>COMPACT STORAGE</code> table with at
least one clustering column supports exactly one (as in not 0 nor more than 1)
column not part of the <code>PRIMARY KEY</code> definition (which imply in
particular that you cannot add nor remove columns after creation). For those
reasons, <code>COMPACT STORA
GE</code> is not recommended outside of the backward compatibility reason
evoked above.</p><p>Another option is <code>CLUSTERING ORDER</code>. It allows
to define the ordering of rows on disk. It takes the list of the clustering
column names with, for each of them, the on-disk order (Ascending or
descending). Note that this option affects <a href="#selectOrderBy">what
<code>ORDER BY</code> are allowed during <code>SELECT</code></a>.</p><p>Table
creation supports the following other
<code><property></code>:</p><table><tr><th>option
</th><th>kind </th><th>default
</th><th>description</th></tr><tr><td><code>comment</code>
</td><td><em>simple</em> </td><td>none </td><td>A free-form,
human-readable comment.</td></tr><tr><td><code>read_repair_chance</code>
</td><td><em>simple</em> </td><td>0.1 </td><td>The probability with
which to query extra nodes (e.g. more nodes than required by the consistency
level) for the purpose
of read repairs.</td></tr><tr><td><code>dclocal_read_repair_chance</code>
</td><td><em>simple</em> </td><td>0 </td><td>The probability with
which to query extra nodes (e.g. more nodes than required by the consistency
level) belonging to the same data center than the read coordinator for the
purpose of read repairs.</td></tr><tr><td><code>gc_grace_seconds</code>
</td><td><em>simple</em> </td><td>864000 </td><td>Time to wait before
garbage collecting tombstones (deletion
markers).</td></tr><tr><td><code>bloom_filter_fp_chance</code>
</td><td><em>simple</em> </td><td>0.00075 </td><td>The target probability
of false positive of the sstable bloom filters. Said bloom filters will be
sized to provide the provided probability (thus lowering this value impact the
size of bloom filters in-memory and
on-disk)</td></tr><tr><td><code>default_time_to_live</code>
</td><td><em>simple</em> </td><td>0 </td><td>The default expiration
time («TTL
7;) in seconds for a table.</td></tr><tr><td><code>compaction</code>
</td><td><em>map</em> </td><td><em>see below</em> </td><td>Compaction
options, see <a
href="#compactionOptions">below</a>.</td></tr><tr><td><code>compression</code>
</td><td><em>map</em> </td><td><em>see below</em>
</td><td>Compression options, see <a
href="#compressionOptions">below</a>.</td></tr><tr><td><code>caching</code>
</td><td><em>map</em> </td><td><em>see below</em>
</td><td>Caching options, see <a
href="#cachingOptions">below</a>.</td></tr></table><h4
id="compactionOptions">Compaction options</h4><p>The <code>compaction</code>
property must at least define the <code>'class'</code> sub-option, that defines
the compaction strategy class to use. The default supported class are
<code>'SizeTieredCompactionStrategy'</code>,
<code>'LeveledCompactionStrategy'</code> and
<code>'DateTieredCompactionStrategy'</code>. Custom strategy can be provided by
specif
ying the full class name as a <a href="#constants">string constant</a>. The
rest of the sub-options depends on the chosen class. The sub-options supported
by the default classes are:</p><table><tr><th>option
</th><th>supported compaction strategy </th><th>default </th><th>description
</th></tr><tr><td><code>enabled</code>
</td><td><em>all</em> </td><td>true
</td><td>A boolean denoting whether compaction should be enabled or
not.</td></tr><tr><td><code>tombstone_threshold</code>
</td><td><em>all</em> </td><td>0.2
</td><td>A ratio such that if a sstable has more than this ratio of gcable
tombstones over all contained columns, the sstable will be compacted (with no
other sstables) for the purpose of purging those tombstones.
</td></tr><tr><td><code>tombstone_compaction_interval</code>
</td><td><em>all</em> </td><td>1 day </t
d><td>The minimum time to wait after an sstable creation time before
considering it for «tombstone compaction», where «tombstone
compaction» is the compaction triggered if the sstable has more gcable
tombstones than <code>tombstone_threshold</code>.
</td></tr><tr><td><code>unchecked_tombstone_compaction</code>
</td><td><em>all</em> </td><td>false
</td><td>Setting this to true enables more aggressive tombstone compactions
– single sstable tombstone compactions will run without checking how
likely it is that they will be successful.
</td></tr><tr><td><code>min_sstable_size</code>
</td><td>SizeTieredCompactionStrategy </td><td>50MB </td><td>The
size tiered strategy groups SSTables to compact in buckets. A bucket groups
SSTables that differs from less than 50% in size. However, for small sizes,
this would result in a bucketing that is too fine grained.
<code>min_sstable_size</code> defines a size thresh
old (in bytes) below which all SSTables belong to one unique
bucket</td></tr><tr><td><code>min_threshold</code>
</td><td>SizeTieredCompactionStrategy </td><td>4 </td><td>Minimum
number of SSTables needed to start a minor
compaction.</td></tr><tr><td><code>max_threshold</code>
</td><td>SizeTieredCompactionStrategy </td><td>32 </td><td>Maximum
number of SSTables processed by one minor
compaction.</td></tr><tr><td><code>bucket_low</code>
</td><td>SizeTieredCompactionStrategy </td><td>0.5 </td><td>Size
tiered consider sstables to be within the same bucket if their size is within
[average_size * <code>bucket_low</code>, average_size *
<code>bucket_high</code> ] (i.e the default groups sstable whose sizes diverges
by at most 50%)</td></tr><tr><td><code>bucket_high</code>
</td><td>SizeTieredCompactionStrategy </td><td>1.5 </td><td>Size
tiered consider sstables to be w
ithin the same bucket if their size is within [average_size *
<code>bucket_low</code>, average_size * <code>bucket_high</code> ] (i.e the
default groups sstable whose sizes diverges by at most
50%).</td></tr><tr><td><code>sstable_size_in_mb</code>
</td><td>LeveledCompactionStrategy </td><td>5MB </td><td>The
target size (in MB) for sstables in the leveled strategy. Note that while
sstable sizes should stay less or equal to <code>sstable_size_in_mb</code>, it
is possible to exceptionally have a larger sstable as during compaction, data
for a given partition key are never split into 2
sstables</td></tr><tr><td><code>timestamp_resolution</code>
</td><td>DateTieredCompactionStrategy </td><td>MICROSECONDS </td><td>The
timestamp resolution used when inserting data, could be MILLISECONDS,
MICROSECONDS etc (should be understandable by Java
TimeUnit)</td></tr><tr><td><code>base_time_seconds</code>
</td><td>DateTieredCompactionStrategy </
td><td>60 </td><td>The base size of the time windows.
</td></tr><tr><td><code>max_sstable_age_days</code>
</td><td>DateTieredCompactionStrategy </td><td>365
</td><td>SSTables only containing data that is older than this will never be
compacted. </td></tr></table><h4 id="compressionOptions">Compression
options</h4><p>For the <code>compression</code> property, the following
sub-options are available:</p><table><tr><th>option
</th><th>default </th><th>description
</th></tr><tr><td><code>class</code> </td><td>LZ4Compressor
</td><td>The compression algorithm to use. Default compressor are:
LZ4Compressor, SnappyCompressor and DeflateCompressor. Use <code>'enabled' :
false</code> to disable compression. Custom compressor can be provided by
specifying the full class name as a <a href="#constants">string
constant</a>.</td></tr><tr><td><code>enabled</code>
</td><td>true </td><td>By default co
mpression is enabled. To disable it, set <code>enabled</code> to
<code>false</code></td></tr><tr><td><code>chunk_length_in_kb</code>
</td><td>64KB </td><td>On disk SSTables are compressed by block (to
allow random reads). This defines the size (in KB) of said block. Bigger values
may improve the compression rate, but increases the minimum size of data to be
read from disk for a read </td></tr><tr><td><code>crc_check_chance</code>
</td><td>1.0 </td><td>When compression is enabled, each compressed
block includes a checksum of that block for the purpose of detecting disk
bitrot and avoiding the propagation of corruption to other replica. This option
defines the probability with which those checksums are checked during read. By
default they are always checked. Set to 0 to disable checksum checking and to
0.5 for instance to check them every other read</td></tr></table><h4
id="cachingOptions">Caching options</h4><p>For the <code>caching</code>
property,
the following sub-options are available:</p><table><tr><th>option
</th><th>default </th><th>description
</th></tr><tr><td><code>keys</code> </td><td>ALL
</td><td>Whether to cache keys («key cache») for this table. Valid
values are: <code>ALL</code> and
<code>NONE</code>.</td></tr><tr><td><code>rows_per_partition</code>
</td><td>NONE </td><td>The amount of rows to cache per partition («row
cache»). If an integer <code>n</code> is specified, the first
<code>n</code> queried rows of a partition will be cached. Other possible
options are <code>ALL</code>, to cache all rows of a queried partition, or
<code>NONE</code> to disable row caching.</td></tr></table><h4
id="Otherconsiderations">Other considerations:</h4><ul><li>When <a
href="#insertStmt">inserting</a> / <a href="#updateStmt">updating</a> a given
row, not all columns needs to be defined (except for those part of the key),
and missing columns occupy no space on disk. F
urthermore, adding new columns (see <a href=#alterStmt><tt>ALTER
TABLE</tt></a>) is a constant time operation. There is thus no need to try to
anticipate future usage (or to cry when you haven’t) when creating a
table.</li></ul><h3 id="alterTableStmt">ALTER
TABLE</h3><p><i>Syntax:</i></p><pre class="syntax"><pre><alter-table-stmt>
::= ALTER (TABLE | COLUMNFAMILY) <tablename> <instruction>
<instruction> ::= ALTER <identifier> TYPE <type>
| ADD <identifier> <type>
@@ -141,7 +141,7 @@ DROP INDEX userkeyspace.address_index;
</pre></pre><p><br/>The <code>DROP INDEX</code> statement is used to drop an
existing secondary index. The argument of the statement is the index name,
which may optionally specify the keyspace of the index.</p><p>If the index 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="createMVStmt">CREATE
MATERIALIZED VIEW</h3><p><i>Syntax:</i></p><pre
class="syntax"><pre><create-table-stmt> ::= CREATE MATERIALIZED VIEW ( IF
NOT EXISTS )? <viewname> AS
SELECT ( '(' <identifier> ( ',' <identifier> )
* ')' | '*' )
FROM <tablename>
- WHERE ( <identifier> IS NOT NULL ( AND
<identifier> IS NOT NULL )* )?
+ ( WHERE <where-clause> )?
PRIMARY KEY '(' <partition-key> ( ','
<identifier> )* ')'
( WITH <option> ( AND <option>)* )?
</pre></pre><p><br/><i>Sample:</i></p><pre class="sample"><pre>CREATE
MATERIALIZED VIEW monkeySpecies_by_population AS
@@ -150,7 +150,7 @@ DROP INDEX userkeyspace.address_index;
WHERE population IS NOT NULL AND species IS NOT NULL
PRIMARY KEY (population, species)
WITH comment='Allow query by population instead of species';
-</pre></pre><p><br/>The <code>CREATE MATERIALIZED VIEW</code> statement
creates a new materialized view. Each such view is a set of <em>rows</em> which
corresponds to rows which are present in the underlying, or base, table
specified in the <code>SELECT</code> statement. A materialized view cannot be
directly updated, but updates to the base table will cause corresponding
updates in the view.</p><p>Attempting to create an already existing
materialized view will return an error unless the <code>IF NOT EXISTS</code>
option is used. If it is used, the statement will be a no-op if the
materialized view already exists.</p><h4 id="createMVWhere"><code>WHERE
<identifier> IS NOT NULL</code></h4><p>The where clause is required to
explicitly exclude all primary key columns' null values. Any row which contains
null values in the primary key will not be present in the materialized
view.</p><h3 id="alterMVStmt">ALTER MATERIALIZED
VIEW</h3><p><i>Syntax:</i></p><pre class="syntax"><pre><alte
r-materialized-view-stmt> ::= ALTER MATERIALIZED VIEW <viewname>
+</pre></pre><p><br/>The <code>CREATE MATERIALIZED VIEW</code> statement
creates a new materialized view. Each such view is a set of <em>rows</em> which
corresponds to rows which are present in the underlying, or base, table
specified in the <code>SELECT</code> statement. A materialized view cannot be
directly updated, but updates to the base table will cause corresponding
updates in the view.</p><p>Attempting to create an already existing
materialized view will return an error unless the <code>IF NOT EXISTS</code>
option is used. If it is used, the statement will be a no-op if the
materialized view already exists.</p><h4 id="createMVWhere"><code>WHERE</code>
Clause</h4><p>The <code><where-clause></code> is similar to the <a
href="#selectWhere">where clause of a <code>SELECT</code> statement</a>, with a
few differences. First, the where clause must contain an expression that
disallows <code>NULL</code> values in columns in the view’s primary key.
If no other restriction is
desired, this can be accomplished with an <code>IS NOT NULL</code>
expression. Second, only columns which are in the base table’s primary
key may be restricted with expressions other than <code>IS NOT NULL</code>.
(Note that this second restriction may be lifted in the future.)</p><h3
id="alterMVStmt">ALTER MATERIALIZED VIEW</h3><p><i>Syntax:</i></p><pre
class="syntax"><pre><alter-materialized-view-stmt> ::= ALTER MATERIALIZED
VIEW <viewname>
WITH <option> ( AND
<option> )*
</pre></pre><p>p.<br/>The <code>ALTER MATERIALIZED VIEW</code> statement
allows options to be update; these options are the same as <a
href="#createTableOptions"><code>CREATE TABLE</code>'s options</a>.</p><h3
id="dropMVStmt">DROP MATERIALIZED VIEW</h3><p><i>Syntax:</i></p><pre
class="syntax"><pre><drop-materialized-stmt> ::= DROP MATERIALIZED VIEW ( IF
EXISTS )? <tablename>
</pre></pre><p><i>Sample:</i></p><pre class="sample"><pre>DROP MATERIALIZED
VIEW monkeySpecies_by_population;
@@ -296,7 +296,7 @@ SET director = 'Joss Whedon',
WHERE movie = 'Serenity';
UPDATE UserActions SET total = total + 2 WHERE user =
B70DE1D0-9908-4AE3-BE34-5573E5B09F14 AND action = 'click';
-</pre></pre><p><br/>The <code>UPDATE</code> statement writes one or more
columns for a given row in a table. The <code><where-clause></code> is used
to select the row to update and must include all columns composing the
<code>PRIMARY KEY</code> (the <code>IN</code> relation is only supported for
the last column of the partition key). Other columns values are specified
through <code><assignment></code> after the <code>SET</code>
keyword.</p><p>Note that unlike in SQL, <code>UPDATE</code> does not check the
prior existence of the row by default: the row is created if none existed
before, and updated otherwise. Furthermore, there is no mean to know which of
creation or update happened.</p><p>It is however possible to use the conditions
on some columns through <code>IF</code>, in which case the row will not be
updated unless such condition are met. But please note that using
<code>IF</code> conditions will incur a non negligible performance cost
(internally, Paxos will be used) so
this should be used sparingly.</p><p>In an <code>UPDATE</code> statement, all
updates within the same partition key are applied atomically and in
isolation.</p><p>The <code>c = c + 3</code> form of
<code><assignment></code> is used to increment/decrement counters. The
identifier after the ‘=’ sign <strong>must</strong> be the same
than the one before the ‘=’ sign (Only increment/decrement is
supported on counters, not the assignment of a specific value).</p><p>The
<code>id = id + <collection-literal></code> and <code>id[value1] =
value2</code> forms of <code><assignment></code> are for collections. Please
refer to the <a href="#collections">relevant section</a> for more
details.</p><h4 id="updateOptions"><code><options></code></h4><p>The
<code>UPDATE</code> and <code>INSERT</code> statements allows to specify the
following options for the insertion:</p><ul><li><code>TIMESTAMP</code>: sets
the timestamp for the operation. If not specified, the coo
rdinator will use the current time (in microseconds) at the start of statement
execution as the timestamp. This is usually a suitable
default.</li><li><code>TTL</code>: allows to specify an optional Time To Live
(in seconds) for the inserted values. If set, the inserted values are
automatically removed from the database after the specified time. Note that the
TTL concerns the inserted values, not the column themselves. This means that
any subsequent update of the column will also reset the TTL (to whatever TTL is
specified in that update). By default, values never expire. A TTL of 0 or a
negative one is equivalent to no TTL.</li></ul><h3
id="deleteStmt">DELETE</h3><p><i>Syntax:</i></p><pre
class="syntax"><pre><delete-stmt> ::= DELETE ( <selection> ( ','
<selection> )* )?
+</pre></pre><p><br/>The <code>UPDATE</code> statement writes one or more
columns for a given row in a table. The <code><where-clause></code> is used
to select the row to update and must include all columns composing the
<code>PRIMARY KEY</code>. Other columns values are specified through
<code><assignment></code> after the <code>SET</code> keyword.</p><p>Note
that unlike in SQL, <code>UPDATE</code> does not check the prior existence of
the row by default: the row is created if none existed before, and updated
otherwise. Furthermore, there are no means to know whether a creation or update
occurred.</p><p>It is however possible to use the conditions on some columns
through <code>IF</code>, in which case the row will not be updated unless the
conditions are met. But, please note that using <code>IF</code> conditions will
incur a non-negligible performance cost (internally, Paxos will be used) so
this should be used sparingly.</p><p>In an <code>UPDATE</code> statement, all
updates
within the same partition key are applied atomically and in
isolation.</p><p>The <code>c = c + 3</code> form of
<code><assignment></code> is used to increment/decrement counters. The
identifier after the ‹=› sign <strong>must</strong> be the same
than the one before the ‹=› sign (Only increment/decrement is
supported on counters, not the assignment of a specific value).</p><p>The
<code>id = id + <collection-literal></code> and <code>id[value1] =
value2</code> forms of <code><assignment></code> are for collections. Please
refer to the <a href="#collections">relevant section</a> for more
details.</p><h4 id="updateOptions"><code><options></code></h4><p>The
<code>UPDATE</code> and <code>INSERT</code> statements support the following
options:</p><ul><li><code>TIMESTAMP</code>: sets the timestamp for the
operation. If not specified, the coordinator will use the current time (in
microseconds) at the start of statement execution as the timestamp. This is
usually a suitable default.</li><li><code>TTL</code>: specifies an optional
Time To Live (in seconds) for the inserted values. If set, the inserted values
are automatically removed from the database after the specified time. Note that
the TTL concerns the inserted values, not the columns themselves. This means
that any subsequent update of the column will also reset the TTL (to whatever
TTL is specified in that update). By default, values never expire. A TTL of 0
or a negative value is equivalent to no TTL.</li></ul><h3
id="deleteStmt">DELETE</h3><p><i>Syntax:</i></p><pre
class="syntax"><pre><delete-stmt> ::= DELETE ( <selection> ( ','
<selection> )* )?
FROM <tablename>
( USING TIMESTAMP <integer>)?
WHERE <where-clause>
@@ -319,7 +319,7 @@ UPDATE UserActions SET total = total + 2
</pre></pre><p><br/><i>Sample:</i></p><pre class="sample"><pre>DELETE FROM
NerdMovies USING TIMESTAMP 1240003134 WHERE movie = 'Serenity';
DELETE phone FROM Users WHERE userid IN (C73DE1D3-AF08-40F3-B124-3FF3E5109F22,
B70DE1D0-9908-4AE3-BE34-5573E5B09F14);
-</pre></pre><p><br/>The <code>DELETE</code> statement deletes columns and
rows. If column names are provided directly after the <code>DELETE</code>
keyword, only those columns are deleted from the row indicated by the
<code><where-clause></code> (the <code>id[value]</code> syntax in
<code><selection></code> is for collection, please refer to the <a
href="#collections">collection section</a> for more details). Otherwise whole
rows are removed. The <code><where-clause></code> allows to specify the key
for the row(s) to delete (the <code>IN</code> relation is only supported for
the last column of the partition key).</p><p><code>DELETE</code> supports the
<code>TIMESTAMP</code> options with the same semantic that in the <a
href="#updateStmt"><code>UPDATE</code></a> statement.</p><p>In a
<code>DELETE</code> statement, all deletions within the same partition key are
applied atomically and in isolation.</p><p>A <code>DELETE</code> operation
application can be conditioned using <c
ode>IF</code> like for <code>UPDATE</code> and <code>INSERT</code>. But please
not that as for the later, this will incur a non negligible performance cost
(internally, Paxos will be used) and so should be used sparingly.</p><h3
id="batchStmt">BATCH</h3><p><i>Syntax:</i></p><pre
class="syntax"><pre><batch-stmt> ::= BEGIN ( UNLOGGED | COUNTER ) BATCH
+</pre></pre><p><br/>The <code>DELETE</code> statement deletes columns and
rows. If column names are provided directly after the <code>DELETE</code>
keyword, only those columns are deleted from the row indicated by the
<code><where-clause></code> (the <code>id[value]</code> syntax in
<code><selection></code> is for collection, please refer to the <a
href="#collections">collection section</a> for more details). Otherwise, whole
rows are removed. The <code><where-clause></code> specifies which rows are
to be deleted. Multiple rows may be deleted with one statement by using an
<code>IN</code> clause. A range of rows may be deleted using an inequality
operator (such as <code>>=</code>).</p><p><code>DELETE</code> supports the
<code>TIMESTAMP</code> option with the same semantics as the <a
href="#updateStmt"><code>UPDATE</code></a> statement.</p><p>In a
<code>DELETE</code> statement, all deletions within the same partition key are
applied atomically and in isolation.</p><p>A <c
ode>DELETE</code> operation can be conditional through the use of an
<code>IF</code> clause, similar to <code>UPDATE</code> and <code>INSERT</code>
statements. However, as with <code>INSERT</code> and <code>UPDATE</code>
statements, this will incur a non-negligible performance cost (internally,
Paxos will be used) and so should be used sparingly.</p><h3
id="batchStmt">BATCH</h3><p><i>Syntax:</i></p><pre
class="syntax"><pre><batch-stmt> ::= BEGIN ( UNLOGGED | COUNTER ) BATCH
( USING <option> ( AND <option> )* )?
<modification-stmt> ( ';' <modification-stmt> )*
APPLY BATCH
@@ -381,7 +381,7 @@ SELECT COUNT(*) FROM users;
SELECT COUNT(*) AS user_count FROM users;
-</pre></pre><p><br/>The <code>SELECT</code> statements reads one or more
columns for one or more rows in a table. It returns a result-set of rows, where
each row contains the collection of columns corresponding to the query. If the
<code>JSON</code> keyword is used, the results for each row will contain only a
single column named “json”. See the section on <a
href="#selectJson"><code>SELECT JSON</code></a> for more details.</p><h4
id="selectSelection"><code><select-clause></code></h4><p>The
<code><select-clause></code> determines which columns needs to be queried
and returned in the result-set. It consists of either the comma-separated list
of <selector> or the wildcard character (<code>*</code>) to select all the
columns defined for the table.</p><p>A <code><selector></code> is either a
column name to retrieve or a <code><function></code> of one or more
@<term>@s. The function allowed are the same as for <code><term></code> and
are described in the <a h
ref="#functions">function section</a>. In addition to these generic functions,
the <code>WRITETIME</code> (resp. <code>TTL</code>) function allows to select
the timestamp of when the column was inserted (resp. the time to live (in
seconds) for the column (or null if the column has no expiration
set)).</p><p>Any <code><selector></code> can be aliased using
<code>AS</code> keyword (see examples). Please note that
<code><where-clause></code> and <code><order-by></code> clause should
refer to the columns by their original names and not by their
aliases.</p><p>The <code>COUNT</code> keyword can be used with parenthesis
enclosing <code>*</code>. If so, the query will return a single result: the
number of rows matching the query. Note that <code>COUNT(1)</code> is supported
as an alias.</p><h4 id="selectWhere"><code><where-clause></code></h4><p>The
<code><where-clause></code> specifies which rows must be queried. It is
composed of relations on the columns that are part of th
e <code>PRIMARY KEY</code> and/or have a <a href="#createIndexStmt">secondary
index</a> defined on them.</p><p>Not all relations are allowed in a query. For
instance, non-equal relations (where <code>IN</code> is considered as an equal
relation) on a partition key are not supported (but see the use of the
<code>TOKEN</code> method below to do non-equal queries on the partition key).
Moreover, for a given partition key, the clustering columns induce an ordering
of rows and relations on them is restricted to the relations that allow to
select a <strong>contiguous</strong> (for the ordering) set of rows. For
instance, given</p><pre class="sample"><pre>CREATE TABLE posts (
+</pre></pre><p><br/>The <code>SELECT</code> statements reads one or more
columns for one or more rows in a table. It returns a result-set of rows, where
each row contains the collection of columns corresponding to the query. If the
<code>JSON</code> keyword is used, the results for each row will contain only a
single column named «json». See the section on <a
href="#selectJson"><code>SELECT JSON</code></a> for more details.</p><h4
id="selectSelection"><code><select-clause></code></h4><p>The
<code><select-clause></code> determines which columns needs to be queried
and returned in the result-set. It consists of either the comma-separated list
of <selector> or the wildcard character (<code>*</code>) to select all the
columns defined for the table.</p><p>A <code><selector></code> is either a
column name to retrieve or a <code><function></code> of one or more
@<term>@s. The function allowed are the same as for <code><term></code> and
are described in the <a hre
f="#functions">function section</a>. In addition to these generic functions,
the <code>WRITETIME</code> (resp. <code>TTL</code>) function allows to select
the timestamp of when the column was inserted (resp. the time to live (in
seconds) for the column (or null if the column has no expiration
set)).</p><p>Any <code><selector></code> can be aliased using
<code>AS</code> keyword (see examples). Please note that
<code><where-clause></code> and <code><order-by></code> clause should
refer to the columns by their original names and not by their
aliases.</p><p>The <code>COUNT</code> keyword can be used with parenthesis
enclosing <code>*</code>. If so, the query will return a single result: the
number of rows matching the query. Note that <code>COUNT(1)</code> is supported
as an alias.</p><h4 id="selectWhere"><code><where-clause></code></h4><p>The
<code><where-clause></code> specifies which rows must be queried. It is
composed of relations on the columns that are part of the
<code>PRIMARY KEY</code> and/or have a <a href="#createIndexStmt">secondary
index</a> defined on them.</p><p>Not all relations are allowed in a query. For
instance, non-equal relations (where <code>IN</code> is considered as an equal
relation) on a partition key are not supported (but see the use of the
<code>TOKEN</code> method below to do non-equal queries on the partition key).
Moreover, for a given partition key, the clustering columns induce an ordering
of rows and relations on them is restricted to the relations that allow to
select a <strong>contiguous</strong> (for the ordering) set of rows. For
instance, given</p><pre class="sample"><pre>CREATE TABLE posts (
userid text,
blog_title text,
posted_at timestamp,
@@ -394,10 +394,10 @@ SELECT COUNT(*) AS user_count FROM users
</pre></pre><p>But the following one is not, as it does not select a
contiguous set of rows (and we suppose no secondary indexes are set):</p><pre
class="sample"><pre>// Needs a blog_title to be set to select ranges of
posted_at
SELECT entry_title, content FROM posts WHERE userid='john doe' AND posted_at
>= '2012-01-01' AND posted_at < '2012-01-31'
</pre></pre><p>When specifying relations, the <code>TOKEN</code> function can
be used on the <code>PARTITION KEY</code> column to query. In that case, rows
will be selected based on the token of their <code>PARTITION_KEY</code> rather
than on the value. Note that the token of a key depends on the partitioner in
use, and that in particular the RandomPartitioner won’t yield a
meaningful order. Also note that ordering partitioners always order token
values by bytes (so even if the partition key is of type int, <code>token(-1) >
token(0)</code> in particular). Example:</p><pre class="sample"><pre>SELECT *
FROM posts WHERE token(userid) > token('tom') AND token(userid) <
token('bob')
-</pre></pre><p>Moreover, the <code>IN</code> relation is only allowed on the
last column of the partition key and on the last column of the full primary
key.</p><p>It is also possible to “group” <code>CLUSTERING
COLUMNS</code> together in a relation using the tuple notation. For
instance:</p><pre class="sample"><pre>SELECT * FROM posts WHERE userid='john
doe' AND (blog_title, posted_at) > ('John''s Blog', '2012-01-01')
-</pre></pre><p>will request all rows that sorts after the one having
“John's Blog” as <code>blog_tile</code> and
‘2012-01-01’ for <code>posted_at</code> in the clustering order. In
particular, rows having a <code>post_at <= '2012-01-01'</code> will be
returned as long as their <code>blog_title > 'John''s Blog'</code>, which
wouldn’t be the case for:</p><pre class="sample"><pre>SELECT * FROM posts
WHERE userid='john doe' AND blog_title > 'John''s Blog' AND posted_at >
'2012-01-01'
+</pre></pre><p>Moreover, the <code>IN</code> relation is only allowed on the
last column of the partition key and on the last column of the full primary
key.</p><p>It is also possible to «group» <code>CLUSTERING
COLUMNS</code> together in a relation using the tuple notation. For
instance:</p><pre class="sample"><pre>SELECT * FROM posts WHERE userid='john
doe' AND (blog_title, posted_at) > ('John''s Blog', '2012-01-01')
+</pre></pre><p>will request all rows that sorts after the one having
«John's Blog» as <code>blog_tile</code> and ‹2012-01-01›
for <code>posted_at</code> in the clustering order. In particular, rows having
a <code>post_at <= '2012-01-01'</code> will be returned as long as their
<code>blog_title > 'John''s Blog'</code>, which wouldn’t be the case
for:</p><pre class="sample"><pre>SELECT * FROM posts WHERE userid='john doe'
AND blog_title > 'John''s Blog' AND posted_at > '2012-01-01'
</pre></pre><p>The tuple notation may also be used for <code>IN</code> clauses
on <code>CLUSTERING COLUMNS</code>:</p><pre class="sample"><pre>SELECT * FROM
posts WHERE userid='john doe' AND (blog_title, posted_at) IN (('John''s Blog',
'2012-01-01), ('Extreme Chess', '2014-06-01'))
-</pre></pre><p>The <code>CONTAINS</code> operator may only be used on
collection columns (lists, sets, and maps). In the case of maps,
<code>CONTAINS</code> applies to the map values. The <code>CONTAINS KEY</code>
operator may only be used on map columns and applies to the map keys.</p><h4
id="selectOrderBy"><code><order-by></code></h4><p>The <code>ORDER BY</code>
option allows to select the order of the returned results. It takes as argument
a list of column names along with the order for the column (<code>ASC</code>
for ascendant and <code>DESC</code> for descendant, omitting the order being
equivalent to <code>ASC</code>). Currently the possible orderings are limited
(which depends on the table <a href="#createTableOptions"><code>CLUSTERING
ORDER</code></a> ):</p><ul><li>if the table has been defined without any
specific <code>CLUSTERING ORDER</code>, then then allowed orderings are the
order induced by the clustering columns and the reverse of that
one.</li><li>otherwise, th
e orderings allowed are the order of the <code>CLUSTERING ORDER</code> option
and the reversed one.</li></ul><h4
id="selectLimit"><code>LIMIT</code></h4><p>The <code>LIMIT</code> option to a
<code>SELECT</code> statement limits the number of rows returned by a
query.</p><h4 id="selectAllowFiltering"><code>ALLOW FILTERING</code></h4><p>By
default, CQL only allows select queries that don’t involve
“filtering” server side, i.e. queries where we know that all (live)
record read will be returned (maybe partly) in the result set. The reasoning is
that those “non filtering” queries have predictable performance in
the sense that they will execute in a time that is proportional to the amount
of data <strong>returned</strong> by the query (which can be controlled through
<code>LIMIT</code>).</p><p>The <code>ALLOW FILTERING</code> option allows to
explicitly allow (some) queries that require filtering. Please note that a
query using <code>ALLOW FILTERING</code> ma
y thus have unpredictable performance (for the definition above), i.e. even a
query that selects a handful of records <strong>may</strong> exhibit
performance that depends on the total amount of data stored in the
cluster.</p><p>For instance, considering the following table holding user
profiles with their year of birth (with a secondary index on it) and country of
residence:</p><pre class="sample"><pre>CREATE TABLE users (
+</pre></pre><p>The <code>CONTAINS</code> operator may only be used on
collection columns (lists, sets, and maps). In the case of maps,
<code>CONTAINS</code> applies to the map values. The <code>CONTAINS KEY</code>
operator may only be used on map columns and applies to the map keys.</p><h4
id="selectOrderBy"><code><order-by></code></h4><p>The <code>ORDER BY</code>
option allows to select the order of the returned results. It takes as argument
a list of column names along with the order for the column (<code>ASC</code>
for ascendant and <code>DESC</code> for descendant, omitting the order being
equivalent to <code>ASC</code>). Currently the possible orderings are limited
(which depends on the table <a href="#createTableOptions"><code>CLUSTERING
ORDER</code></a> ):</p><ul><li>if the table has been defined without any
specific <code>CLUSTERING ORDER</code>, then then allowed orderings are the
order induced by the clustering columns and the reverse of that
one.</li><li>otherwise, th
e orderings allowed are the order of the <code>CLUSTERING ORDER</code> option
and the reversed one.</li></ul><h4
id="selectLimit"><code>LIMIT</code></h4><p>The <code>LIMIT</code> option to a
<code>SELECT</code> statement limits the number of rows returned by a
query.</p><h4 id="selectAllowFiltering"><code>ALLOW FILTERING</code></h4><p>By
default, CQL only allows select queries that don’t involve
«filtering» server side, i.e. queries where we know that all (live)
record read will be returned (maybe partly) in the result set. The reasoning is
that those «non filtering» queries have predictable performance in
the sense that they will execute in a time that is proportional to the amount
of data <strong>returned</strong> by the query (which can be controlled through
<code>LIMIT</code>).</p><p>The <code>ALLOW FILTERING</code> option allows to
explicitly allow (some) queries that require filtering. Please note that a
query using <code>ALLOW FILTERING</code> may th
us have unpredictable performance (for the definition above), i.e. even a
query that selects a handful of records <strong>may</strong> exhibit
performance that depends on the total amount of data stored in the
cluster.</p><p>For instance, considering the following table holding user
profiles with their year of birth (with a secondary index on it) and country of
residence:</p><pre class="sample"><pre>CREATE TABLE users (
username text PRIMARY KEY,
firstname text,
lastname text,
@@ -409,7 +409,7 @@ CREATE INDEX ON users(birth_year);
</pre></pre><p></p><p>Then the following queries are valid:</p><pre
class="sample"><pre>SELECT * FROM users;
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><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="databaseRoles">Database Roles</h2><h3
id="createRoleStmt">CREATE ROLE</h3><p><i>Syntax:</i></p><pre
class="syntax"><pre><create-role-stmt> ::= CREATE ROLE ( IF NOT EXISTS )?
<identifier> ( WITH <option> ( AND <option> )* )?
<option> ::= PASSWORD = <string>
@@ -553,7 +553,7 @@ REVOKE DESCRIBE ON ALL ROLES FROM role_a
| set '<' <native-type> '>'
| map '<' <native-type> ',' <native-type> '>'
<tuple-type> ::= tuple '<' <type> (',' <type>)* '>'
[... 33 lines stripped ...]