Database Reference
In-Depth Information
DROP KEYSPACE
DATABASE
command. This operation is irreversible and removes all information
within the specified keyspace.
Listing 4.4
Example Usage of
DROP KEYSPACE
DROP KEYSPACE Analytics;
CREATE TABLE/COLUMNFAMILY
The
CREATE TABLE
statement creates a table. A table is defined as a collection
of rows and columns.
CREATE COLUMNFAMILY
is an alias for
CREATE
TABLE
.
Primary Keys
The
PRIMARY KEY
in the table definition defines the physical key in the un-
derlying Cassandra data structure. Because of this, the
PRIMARY KEY
must be
defined in the column definitions. Other than this, the syntax is similar to the cor-
responding SQL syntax. When defining the
PRIMARY KEY
, if you decide to use
a compound key, only the first part of the key will be used as the underlying row
key. This is called the partition key. If you want to have a composite partition key,
this is defined by adding a set of parentheses around the parts you would like to
be the partition key. The remaining parts of the compound key will be used as the
physical parts of the composite columns in the underlying data structure. These are
called the clustering keys. The clustering keys will determine the order in which
the columns are stored on disk. You can optionally specify a clustering order that
4.5
demonstrates creating a static table in CQL 3.
Listing 4.5
Example Usage of
CREATE TABLE
for a Static Table
CREATE TABLE users (
email text PRIMARY KEY,
first_name text,
last_name text,