Author: tylerhobbs
Date: Tue Mar  3 20:05:46 2015
New Revision: 1663774

URL: http://svn.apache.org/r1663774
Log:
Update CQL3 docs for CASSANDRA-8889

Modified:
    cassandra/site/publish/doc/cql3/CQL-2.0.html
    cassandra/site/publish/doc/cql3/CQL-2.1.html

Modified: cassandra/site/publish/doc/cql3/CQL-2.0.html
URL: 
http://svn.apache.org/viewvc/cassandra/site/publish/doc/cql3/CQL-2.0.html?rev=1663774&r1=1663773&r2=1663774&view=diff
==============================================================================
--- cassandra/site/publish/doc/cql3/CQL-2.0.html (original)
+++ cassandra/site/publish/doc/cql3/CQL-2.0.html Tue Mar  3 20:05:46 2015
@@ -38,7 +38,7 @@
 
   <properties> ::= <property> (AND <property>)*
     <property> ::= <identifier> '=' ( <identifier> | <constant> | 
<map-literal> )
-</pre></pre><p><br/>Please note that not every possible productions of the 
grammar above will be valid in practice. Most notably, 
<code>&lt;variable></code> and nested <code>&lt;collection-literal></code> are 
currently not allowed inside <code>&lt;collection-literal></code>.</p><p>A 
<code>&lt;variable></code> can be either anonymous (a question mark 
(<code>?</code>)) or named (an identifier preceded by <code>:</code>). Both 
declare a bind variables for <a href="#preparedStatement">prepared 
statements</a>. The only difference between an anymous and a named variable is 
that a named one will be easier to refer to (how exactly depends on the client 
driver used).</p><p>The <code>&lt;properties></code> production is use by 
statement that create and alter keyspaces and tables. Each 
<code>&lt;property></code> is either a <em>simple</em> one, in which case it 
just has a value, or a <em>map</em> one, in which case it&#8217;s value is a 
map grouping sub-options. The following will refer to one
  or the other as the <em>kind</em> (<em>simple</em> or <em>map</em>) of the 
property.</p><p>A <code>&lt;tablename></code> will be used to identify a table. 
This is an identifier representing the table name that can be preceded by a 
keyspace name. The keyspace name, if provided, allow to identify a table in 
another keyspace than the currently active one (the currently active keyspace 
is set through the <a href="#useStmt"><tt>USE</tt></a> statement).</p><p>For 
supported <code>&lt;function></code>, see the section on <a 
href="#functions">functions</a>.</p><h3 id="preparedStatement">Prepared 
Statement</h3><p>CQL supports <em>prepared statements</em>. Prepared statement 
is an optimization that allows to parse a query only once but execute it 
multiple times with different concrete values.</p><p>In a statement, each time 
a column value is expected (in the data manipulation and query statements), a 
<code>&lt;variable></code> (see above) can be used instead. A statement with 
bind variables m
 ust then be <em>prepared</em>. Once it has been prepared, it can executed by 
providing concrete values for the bind variables. The exact procedure to 
prepare a statement and execute a prepared statement depends on the CQL driver 
used and is beyond the scope of this document.</p><h2 id="dataDefinition">Data 
Definition</h2><h3 id="createKeyspaceStmt">CREATE 
KEYSPACE</h3><p><i>Syntax:</i></p><pre 
class="syntax"><pre>&lt;create-keyspace-stmt> ::= CREATE KEYSPACE (IF NOT 
EXISTS)? &lt;identifier> WITH &lt;properties>
+</pre></pre><p><br/>Please note that not every possible productions of the 
grammar above will be valid in practice. Most notably, 
<code>&lt;variable></code> and nested <code>&lt;collection-literal></code> are 
currently not allowed inside <code>&lt;collection-literal></code>.</p><p>A 
<code>&lt;variable></code> can be either anonymous (a question mark 
(<code>?</code>)) or named (an identifier preceded by <code>:</code>). Both 
declare a bind variables for <a href="#preparedStatement">prepared 
statements</a>. The only difference between an anymous and a named variable is 
that a named one will be easier to refer to (how exactly depends on the client 
driver used).</p><p>The <code>&lt;properties></code> production is use by 
statement that create and alter keyspaces and tables. Each 
<code>&lt;property></code> is either a <em>simple</em> one, in which case it 
just has a value, or a <em>map</em> one, in which case it&#8217;s value is a 
map grouping sub-options. The following will refer to one
  or the other as the <em>kind</em> (<em>simple</em> or <em>map</em>) of the 
property.</p><p>A <code>&lt;tablename></code> will be used to identify a table. 
This is an identifier representing the table name that can be preceded by a 
keyspace name. The keyspace name, if provided, allow to identify a table in 
another keyspace than the currently active one (the currently active keyspace 
is set through the <a href="#useStmt"><tt>USE</tt></a> statement).</p><p>For 
supported <code>&lt;function></code>, see the section on <a 
href="#functions">functions</a>.</p><h3 id="preparedStatement">Prepared 
Statement</h3><p>CQL supports <em>prepared statements</em>. Prepared statement 
is an optimization that allows to parse a query only once but execute it 
multiple times with different concrete values.</p><p>In a statement, each time 
a column value is expected (in the data manipulation and query statements), a 
<code>&lt;variable></code> (see above) can be used instead. A statement with 
bind variables m
 ust then be <em>prepared</em>. Once it has been prepared, it can executed by 
providing concrete values for the bind variables. The exact procedure to 
prepare a statement and execute a prepared statement depends on the CQL driver 
used and is beyond the scope of this document.</p><p>In addition to providing 
column values, bind markers may be used to provide values for 
<code>LIMIT</code>, <code>TIMESTAMP</code>, and <code>TTL</code> clauses.  If 
anonymous bind markers are used, the names for the query parameters will be 
<code>[limit]</code>, <code>[timestamp]</code>, and <code>[ttl]</code>, 
respectively.</p><h2 id="dataDefinition">Data Definition</h2><h3 
id="createKeyspaceStmt">CREATE KEYSPACE</h3><p><i>Syntax:</i></p><pre 
class="syntax"><pre>&lt;create-keyspace-stmt> ::= CREATE KEYSPACE (IF NOT 
EXISTS)? &lt;identifier> WITH &lt;properties>
 </pre></pre><p><br/><i>Sample:</i></p><pre class="sample"><pre>CREATE KEYSPACE 
Excelsior
            WITH replication = {'class': 'SimpleStrategy', 'replication_factor' 
: 3};
 
@@ -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 &#8220;shared&#8221; 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>&lt;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>&lt;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>compaction</code>                 
</td><td><em>map</em>    </td><td><em>see below</em> </td><td>The compaction 
options to use, se
 e below.</td></tr><tr><td><code>compression</code>                
</td><td><em>map</em>    </td><td><em>see below</em> </td><td>Compression 
options, see below. </td></tr><tr><td><code>replicate_on_write</code>         
</td><td><em>simple</em> </td><td>true        </td><td>Whether to replicate 
data on write. This can only be set to false for tables with counters values. 
Disabling this is dangerous and can result in random lose of counters, 
don&#8217;t disable unless you are sure to know what you are 
doing</td></tr><tr><td><code>caching</code>                    
</td><td><em>simple</em> </td><td>keys_only   </td><td>Whether to cache keys 
(&#8220;key cache&#8221;) and/or rows (&#8220;row cache&#8221;) for this table. 
Valid values are: <code>all</code>, <code>keys_only</code>, 
<code>rows_only</code> and <code>none</code>. </td></tr></table><h4 
id="compactionOptions"><code>compaction</code> 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> and 
<code>'LeveledCompactionStrategy'</code>. Custom strategy can be provided by 
specifying 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 b
 e 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 
&#8220;tombstone compaction&#8221;, where &#8220;tombstone compaction&#8221; 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 
&#8211; 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 b
 uckets. 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 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></table><p>For 
the <code>compression</code> property, the following default 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 de
 fines 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="Otherconsiderations">Other considerations:</h4><ul><li>When <a 
href="#insertStmt/&quot;updating&quot;:#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 
&lt;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&#8217;t) when creating a table.</li></ul><h3 id="alterTableStmt">ALTER 
TABLE</h3><p><i>Syntax:</i></p><pre class="syntax"><pre>&lt;alter-table-stmt> 
::= ALTER (TABLE | COLUMNFAMILY) &lt;tablename> &lt;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 &#8220;shared&#8221; 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>&lt;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>&lt;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>compaction</code>                 
</td><td><em>map</em>    </td><td><em>see below</em> </td><td>The compaction 
options to use, se
 e below.</td></tr><tr><td><code>compression</code>                
</td><td><em>map</em>    </td><td><em>see below</em> </td><td>Compression 
options, see below. </td></tr><tr><td><code>replicate_on_write</code>         
</td><td><em>simple</em> </td><td>true        </td><td>Whether to replicate 
data on write. This can only be set to false for tables with counters values. 
Disabling this is dangerous and can result in random lose of counters, 
don&#8217;t disable unless you are sure to know what you are 
doing</td></tr><tr><td><code>caching</code>                    
</td><td><em>simple</em> </td><td>keys_only   </td><td>Whether to cache keys 
(&#8220;key cache&#8221;) and/or rows (&#8220;row cache&#8221;) for this table. 
Valid values are: <code>all</code>, <code>keys_only</code>, 
<code>rows_only</code> and <code>none</code>. 
</td></tr><tr><td><code>default_time_to_live</code>       
</td><td><em>simple</em> </td><td>0           </td><td>The default expiration 
time (&#8220;TTL&#8221;) in sec
 onds for a table.</td></tr></table><h4 
id="compactionOptions"><code>compaction</code> 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> and 
<code>'LeveledCompactionStrategy'</code>. Custom strategy can be provided by 
specifying 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>al
 l</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 
&#8220;tombstone compaction&#8221;, where &#8220;tombstone compaction&#8221; 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 
&#8211; single sstable tombstone compactions will run without checking how 
likely it is that they will be successful. </t
 d></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 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 conside
 r 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 s
 stables</td></tr></table><p>For the <code>compression</code> property, the 
following default 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="Otherconsiderations">Other 
considerations:</h4><ul><li>When <a 
href="#insertStmt/&quot;updating&quot;:#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 
&lt;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&#8217;t) when creating a table.</li></ul><h3 id="alterTableStmt">ALTER 
TABLE</h3><p><i>Syntax:</i></p><pre class="syntax"><pre>&l
 t;alter-table-stmt> ::= ALTER (TABLE | COLUMNFAMILY) &lt;tablename> 
&lt;instruction>
 
 &lt;instruction> ::= ALTER &lt;identifier> TYPE &lt;type>
                 | ADD   &lt;identifier> &lt;type>
@@ -171,7 +171,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>&lt;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>&lt;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>&lt;assignment></code> is used to increment/decrement counters. The 
identifier after the &#8216;=&#8217; sign <strong>must</strong> be the same 
than the one before the &#8216;=&#8217; sign (Only increment/decrement is 
supported on counters, not the assignment of a specific value).</p><p>The 
<code>id = id + &lt;collection-literal></code> and <code>id[value1] = 
value2</code> forms of <code>&lt;assignment></code> are for collections. Please 
refer to the <a href="#collections">relevant section</a> for more 
details.</p><h4 id="updateOptions"><code>&lt;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 cur
 rent time of the insertion (in microseconds) is used. 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>&lt;delete-stmt> ::= DELETE ( &lt;selection> ( ',' 
&lt;selection> )* )?
+</pre></pre><p><br/>The <code>UPDATE</code> statement writes one or more 
columns for a given row in a table. The <code>&lt;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>&lt;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>&lt;assignment></code> is used to increment/decrement counters. The 
identifier after the &#8216;=&#8217; sign <strong>must</strong> be the same 
than the one before the &#8216;=&#8217; sign (Only increment/decrement is 
supported on counters, not the assignment of a specific value).</p><p>The 
<code>id = id + &lt;collection-literal></code> and <code>id[value1] = 
value2</code> forms of <code>&lt;assignment></code> are for collections. Please 
refer to the <a href="#collections">relevant section</a> for more 
details.</p><h4 id="updateOptions"><code>&lt;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>&lt;delete-stmt> ::= DELETE ( &lt;selection> ( ',' 
&lt;selection> )* )?
                   FROM &lt;tablename>
                   ( USING TIMESTAMP &lt;integer>)?
                   WHERE &lt;where-clause>

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=1663774&r1=1663773&r2=1663774&view=diff
==============================================================================
--- cassandra/site/publish/doc/cql3/CQL-2.1.html (original)
+++ cassandra/site/publish/doc/cql3/CQL-2.1.html Tue Mar  3 20:05:46 2015
@@ -38,7 +38,7 @@
 
   &lt;properties> ::= &lt;property> (AND &lt;property>)*
     &lt;property> ::= &lt;identifier> '=' ( &lt;identifier> | &lt;constant> | 
&lt;map-literal> )
-</pre></pre><p><br/>Please note that not every possible productions of the 
grammar above will be valid in practice. Most notably, 
<code>&lt;variable></code> and nested <code>&lt;collection-literal></code> are 
currently not allowed inside <code>&lt;collection-literal></code>.</p><p>A 
<code>&lt;variable></code> can be either anonymous (a question mark 
(<code>?</code>)) or named (an identifier preceded by <code>:</code>). Both 
declare a bind variables for <a href="#preparedStatement">prepared 
statements</a>. The only difference between an anymous and a named variable is 
that a named one will be easier to refer to (how exactly depends on the client 
driver used).</p><p>The <code>&lt;properties></code> production is use by 
statement that create and alter keyspaces and tables. Each 
<code>&lt;property></code> is either a <em>simple</em> one, in which case it 
just has a value, or a <em>map</em> one, in which case it&#8217;s value is a 
map grouping sub-options. The following will refer to one
  or the other as the <em>kind</em> (<em>simple</em> or <em>map</em>) of the 
property.</p><p>A <code>&lt;tablename></code> will be used to identify a table. 
This is an identifier representing the table name that can be preceded by a 
keyspace name. The keyspace name, if provided, allow to identify a table in 
another keyspace than the currently active one (the currently active keyspace 
is set through the <a href="#useStmt"><tt>USE</tt></a> statement).</p><p>For 
supported <code>&lt;function></code>, see the section on <a 
href="#functions">functions</a>.</p><h3 id="preparedStatement">Prepared 
Statement</h3><p>CQL supports <em>prepared statements</em>. Prepared statement 
is an optimization that allows to parse a query only once but execute it 
multiple times with different concrete values.</p><p>In a statement, each time 
a column value is expected (in the data manipulation and query statements), a 
<code>&lt;variable></code> (see above) can be used instead. A statement with 
bind variables m
 ust then be <em>prepared</em>. Once it has been prepared, it can executed by 
providing concrete values for the bind variables. The exact procedure to 
prepare a statement and execute a prepared statement depends on the CQL driver 
used and is beyond the scope of this document.</p><h2 id="dataDefinition">Data 
Definition</h2><h3 id="createKeyspaceStmt">CREATE 
KEYSPACE</h3><p><i>Syntax:</i></p><pre 
class="syntax"><pre>&lt;create-keyspace-stmt> ::= CREATE KEYSPACE (IF NOT 
EXISTS)? &lt;identifier> WITH &lt;properties>
+</pre></pre><p><br/>Please note that not every possible productions of the 
grammar above will be valid in practice. Most notably, 
<code>&lt;variable></code> and nested <code>&lt;collection-literal></code> are 
currently not allowed inside <code>&lt;collection-literal></code>.</p><p>A 
<code>&lt;variable></code> can be either anonymous (a question mark 
(<code>?</code>)) or named (an identifier preceded by <code>:</code>). Both 
declare a bind variables for <a href="#preparedStatement">prepared 
statements</a>. The only difference between an anymous and a named variable is 
that a named one will be easier to refer to (how exactly depends on the client 
driver used).</p><p>The <code>&lt;properties></code> production is use by 
statement that create and alter keyspaces and tables. Each 
<code>&lt;property></code> is either a <em>simple</em> one, in which case it 
just has a value, or a <em>map</em> one, in which case it&#8217;s value is a 
map grouping sub-options. The following will refer to one
  or the other as the <em>kind</em> (<em>simple</em> or <em>map</em>) of the 
property.</p><p>A <code>&lt;tablename></code> will be used to identify a table. 
This is an identifier representing the table name that can be preceded by a 
keyspace name. The keyspace name, if provided, allow to identify a table in 
another keyspace than the currently active one (the currently active keyspace 
is set through the <a href="#useStmt"><tt>USE</tt></a> statement).</p><p>For 
supported <code>&lt;function></code>, see the section on <a 
href="#functions">functions</a>.</p><h3 id="preparedStatement">Prepared 
Statement</h3><p>CQL supports <em>prepared statements</em>. Prepared statement 
is an optimization that allows to parse a query only once but execute it 
multiple times with different concrete values.</p><p>In a statement, each time 
a column value is expected (in the data manipulation and query statements), a 
<code>&lt;variable></code> (see above) can be used instead. A statement with 
bind variables m
 ust then be <em>prepared</em>. Once it has been prepared, it can executed by 
providing concrete values for the bind variables. The exact procedure to 
prepare a statement and execute a prepared statement depends on the CQL driver 
used and is beyond the scope of this document.</p><p>In addition to providing 
column values, bind markers may be used to provide values for 
<code>LIMIT</code>, <code>TIMESTAMP</code>, and <code>TTL</code> clauses.  If 
anonymous bind markers are used, the names for the query parameters will be 
<code>[limit]</code>, <code>[timestamp]</code>, and <code>[ttl]</code>, 
respectively.</p><h2 id="dataDefinition">Data Definition</h2><h3 
id="createKeyspaceStmt">CREATE KEYSPACE</h3><p><i>Syntax:</i></p><pre 
class="syntax"><pre>&lt;create-keyspace-stmt> ::= CREATE KEYSPACE (IF NOT 
EXISTS)? &lt;identifier> WITH &lt;properties>
 </pre></pre><p><br/><i>Sample:</i></p><pre class="sample"><pre>CREATE KEYSPACE 
Excelsior
            WITH replication = {'class': 'SimpleStrategy', 'replication_factor' 
: 3};
 


Reply via email to