diff --git a/doc/cql/CQL.html b/doc/cql/CQL.html index 2c6e99e671..1f24af803a 100644 --- a/doc/cql/CQL.html +++ b/doc/cql/CQL.html @@ -1,4 +1,4 @@ -
Synopsis:
USE <KEYSPACE>;
+Cassandra Query Language (CQL) v1.0.0
Table of Contents
- Cassandra Query Language (CQL) v1.0.0
- Versioning
- Changes
USE
Synopsis:
USE <KEYSPACE>;
A USE statement consists of the USE keyword, followed by a valid keyspace name. Its purpose is to assign the per-connection, current working keyspace. All subsequent keyspace-specific actions will be performed in the context of the supplied value.
SELECT
Synopsis:
SELECT [FIRST N] [REVERSED] <SELECT EXPR> FROM <COLUMN FAMILY> [USING <CONSISTENCY>]
[WHERE <CLAUSE>] [LIMIT N];
A SELECT is used to read one or more records from a Cassandra column family. It returns a result-set of rows, where each row consists of a key and a collection of columns corresponding to the query.
Specifying Columns
SELECT [FIRST N] [REVERSED] name1, name2, name3 FROM ...
@@ -28,9 +28,11 @@ UPDATE ... WHERE KEY IN (keyname1, keyname2)
The WHERE clause is used to determine which row(s) a DELETE applies to. The first form allows the specification of a single keyname using the KEY keyword and the = operator. The second form allows a list of keyname terms to be specified using the IN notation and a parenthesized list of comma-delimited keyname terms.
TRUNCATE
Synopsis:
TRUNCATE <COLUMN FAMILY>
Accepts a single argument for the column family name, and permanently removes all data from said column family.
CREATE KEYSPACE
Synopsis:
CREATE KEYSPACE <NAME> WITH replication_factor = <NUM> AND strategy_class = <STRATEGY>
[AND strategy_options.<OPTION> = <VALUE> [AND strategy_options.<OPTION> = <VALUE>]];
-
The CREATE KEYSPACE statement creates a new top-level namespace (aka “keyspace”). Valid names are any string constructed of alphanumeric characters and underscores, but must begin with a letter. Properties such as replication strategy and count are specified during creation using the following accepted keyword arguments:
keyword required description replication_factor yes Numeric argument that specifies the number of replicas for this keyspace. strategy_class yes Class name to use for managing replica placement. Any of the shipped strategies can be used by specifying the class name relative to org.apache.cassandra.locator, others will need to be fully-qualified and located on the classpath. strategy_options no Some strategies require additional arguments which can be supplied by appending the option name to the strategy_options keyword, separated by a colon (:). For example, a strategy option of “DC1” with a value of “1” would be specified as strategy_options:DC1 = 1.
CREATE COLUMNFAMILY
Synopsis:
CREATE COLUMNFAMILY <COLUMN FAMILY> [(name1 type, name2 type, ...)] [WITH keyword1 = arg1
- [AND keyword2 = arg2 [AND ...]]];
-
CREATE COLUMNFAMILY statements create new column family namespaces under the current keyspace. Valid column family names are strings of alphanumeric characters and underscores, which begin with a letter.
Specifying Column Type (optional)
CREATE COLUMNFAMILY <COLUMN FAMILY> (name1 type, name2 type) ...;
+
The CREATE KEYSPACE statement creates a new top-level namespace (aka “keyspace”). Valid names are any string constructed of alphanumeric characters and underscores, but must begin with a letter. Properties such as replication strategy and count are specified during creation using the following accepted keyword arguments:
keyword required description replication_factor yes Numeric argument that specifies the number of replicas for this keyspace. strategy_class yes Class name to use for managing replica placement. Any of the shipped strategies can be used by specifying the class name relative to org.apache.cassandra.locator, others will need to be fully-qualified and located on the classpath. strategy_options no Some strategies require additional arguments which can be supplied by appending the option name to the strategy_options keyword, separated by a colon (:). For example, a strategy option of “DC1” with a value of “1” would be specified as strategy_options:DC1 = 1.
CREATE COLUMNFAMILY
Synopsis:
CREATE COLUMNFAMILY <COLUMN FAMILY> (KEY <type> PRIMARY KEY [, name1 type, name2 type, ...]);
+CREATE COLUMNFAMILY <COLUMN FAMILY> (KEY <type> PRIMARY KEY [, name1 type, name2 type, ...])
+ [WITH keyword1 = arg1 [AND keyword2 = arg2 [AND ...]]];
+
CREATE COLUMNFAMILY statements create new column family namespaces under the current keyspace. Valid column family names are strings of alphanumeric characters and underscores, which begin with a letter.
Specifying Key Type
CREATE ... (KEY <type> PRIMARY KEY) ...
+
When creating a new column family, you must specify key type. The list of possible key types is identical to column comparators/validators, (see Specifying Column Type). It’s important to note that the key type must be compatible with the partitioner in use, for example OrderPreservingPartitioner and CollatingOrderPreservingPartitioner both require UTF-8 keys.
Specifying Column Type (optional)
CREATE ... (KEY <type> PRIMARY KEY, name1 type, name2 type) ...
It is possible to assign columns a type during column family creation. Columns configured with a type are validated accordingly when a write occurs. Column types are specified as a parenthesized, comma-separated list of column term and type pairs. The list of recognized types are:
type description bytes Arbitrary bytes (no validation) ascii ASCII character string utf8 UTF8 encoded string timeuuid Type 1 UUID uuid Type 4 UUID int 4-byte integer long 8-byte long
Note: In addition to the recognized types listed above, it is also possible to supply a string containing the name of a class (a sub-class of AbstractType), either fully qualified, or relative to the org.apache.cassandra.db.marshal package.
Column Family Options (optional)
CREATE COLUMNFAMILY ... WITH keyword1 = arg1 AND keyword2 = arg2;
A number of optional keyword arguments can be supplied to control the configuration of a new column family.
keyword default description comparator utf8 Determines sorting and validation of column names. Valid values are identical to the types listed in Specifying Column Type above. comment none A free-form, human-readable comment. row_cache_size 0 Number of rows whose entire contents to cache in memory. key_cache_size 200000 Number of keys per SSTable whose locations are kept in memory in “mostly LRU” order. read_repair_chance 1.0 The probability with which read repairs should be invoked on non-quorum reads. gc_grace_seconds 864000 Time to wait before garbage collecting tombstones (deletion markers). default_validation utf8 Determines validation of column values. Valid values are identical to the types listed in Specifying Column Type above. min_compaction_threshold 4 Minimum number of SSTables needed to start a minor compaction. max_compaction_threshold 32 Maximum number of SSTables allowed before a minor compaction is forced. row_cache_save_period_in_seconds 0 Number of seconds between saving row caches. key_cache_save_period_in_seconds 14400 Number of seconds between saving key caches. memtable_flush_after_mins 60 Maximum time to leave a dirty table unflushed. memtable_throughput_in_mb dynamic Maximum size of the memtable before it is flushed. memtable_operations_in_millions dynamic Number of operations in millions before the memtable is flushed. replicate_on_write false
CREATE INDEX
Synopsis:
CREATE INDEX [index_name] ON <column_family> (column_name);
A CREATE INDEX statement is used to create a new, automatic secondary index for the named column.
DROP
Synopsis:
DROP <KEYSPACE|COLUMNFAMILY> namespace;
diff --git a/doc/cql/CQL.textile b/doc/cql/CQL.textile
index f08be160bf..4c31ddac4a 100644
--- a/doc/cql/CQL.textile
+++ b/doc/cql/CQL.textile
@@ -180,15 +180,23 @@ h2. CREATE COLUMNFAMILY
_Synopsis:_
bc.
-CREATE COLUMNFAMILY [(name1 type, name2 type, ...)] [WITH keyword1 = arg1
- [AND keyword2 = arg2 [AND ...]]];
+CREATE COLUMNFAMILY (KEY PRIMARY KEY [, name1 type, name2 type, ...]);
+CREATE COLUMNFAMILY (KEY PRIMARY KEY [, name1 type, name2 type, ...])
+ [WITH keyword1 = arg1 [AND keyword2 = arg2 [AND ...]]];
@CREATE COLUMNFAMILY@ statements create new column family namespaces under the current keyspace. Valid column family names are strings of alphanumeric characters and underscores, which begin with a letter.
+h3(#keytypes). Specifying Key Type
+
+bc.
+CREATE ... (KEY PRIMARY KEY) ...
+
+When creating a new column family, you must specify key type. The list of possible key types is identical to column comparators/validators, (see "Specifying Column Type":columntypes). It's important to note that the key type must be compatible with the partitioner in use, for example @OrderPreservingPartitioner@ and @CollatingOrderPreservingPartitioner@ both require UTF-8 keys.
+
h3(#columntypes). Specifying Column Type (optional)
bc.
-CREATE COLUMNFAMILY (name1 type, name2 type) ...;
+CREATE ... (KEY PRIMARY KEY, name1 type, name2 type) ...
It is possible to assign columns a type during column family creation. Columns configured with a type are validated accordingly when a write occurs. Column types are specified as a parenthesized, comma-separated list of column term and type pairs. The list of recognized types are: