Author: slebresne
Date: Thu Mar 17 09:27:25 2016
New Revision: 1735378
URL: http://svn.apache.org/viewvc?rev=1735378&view=rev
Log:
Update CQL doc post-CASSANDRA-10752
Modified:
cassandra/site/publish/doc/cql3/CQL-2.1.html
cassandra/site/publish/doc/cql3/CQL-2.2.html
cassandra/site/publish/doc/cql3/CQL-3.0.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=1735378&r1=1735377&r2=1735378&view=diff
==============================================================================
--- cassandra/site/publish/doc/cql3/CQL-2.1.html (original)
+++ cassandra/site/publish/doc/cql3/CQL-2.1.html Thu Mar 17 09:27:25 2016
@@ -101,7 +101,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>sstable_compression</code> </td><td>LZ4Compressor
</td><td>The compression algorithm to use. Default compressor are:
LZ4Compressor, SnappyCompressor and DeflateCompressor. Use an empty string
(<code>''</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>chunk_length_kb</code> </td><td>64KB
</td><td>On disk SST
ables 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/"updating":#updateStmt">inserting</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. 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</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) - don’t
change this unless you do mutations with USING TIMESTAMP
<non_microsecond_timestam
ps> (or equivalent directly in the
client)</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>sstable_compression</code> </td><td>LZ4Compressor
</td><td>The compression algorithm to use. Default compressor are:
LZ4Compressor, SnappyCompressor and DeflateCompressor. Use an empty string
(<code>''</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>chunk_length_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><t
able><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/"updating":#updateStmt">inserting</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. 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>
<instruction> ::= ALTER <identifier> TYPE <type>
| ADD <identifier> <type>
@@ -199,14 +199,18 @@ USING TTL 86400;
| <identifier> '=' <identifier> '+' <map-literal>
| <identifier> '[' <term> ']' '=' <term>
-<condition> ::= <identifier> '=' <term>
- | <identifier> '[' <term> ']' '=' <term>
+<condition> ::= <identifier> <op> <term>
+ | <identifier> IN (<variable> | '(' ( <term> ( ','
<term> )* )? ')')
+ | <identifier> '[' <term> ']' <op> <term>
+ | <identifier> '[' <term> ']' IN <term>
+
+<op> ::= '<' | '<=' | '=' | '!=' | '>=' | '>'
<where-clause> ::= <relation> ( AND <relation> )*
<relation> ::= <identifier> '=' <term>
| <identifier> IN '(' ( <term> ( ',' <term> )* )? ')'
- | <identifier> IN '?'
+ | <identifier> IN <variable>
<option> ::= TIMESTAMP <integer>
| TTL <integer>
@@ -217,7 +221,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> (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 (except through the use of
<code><condition></code>, see below): 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</cod
e>: 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>:
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> )* )?
FROM <tablename>
( USING TIMESTAMP <integer>)?
WHERE <where-clause>
@@ -229,10 +233,14 @@ UPDATE UserActions SET total = total + 2
<relation> ::= <identifier> '=' <term>
| <identifier> IN '(' ( <term> ( ',' <term> )* )? ')'
- | <identifier> IN '?'
+ | <identifier> IN <variable>
+
+<condition> ::= <identifier> <op> <term>
+ | <identifier> IN (<variable> | '(' ( <term> ( ','
<term> )* )? ')')
+ | <identifier> '[' <term> ']' <op> <term>
+ | <identifier> '[' <term> ']' IN <term>
-<condition> ::= <identifier> '=' <term>
- | <identifier> '[' <term> ']' '=' <term>
+<op> ::= '<' | '<=' | '=' | '!=' | '>=' | '>'
</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);