Database Reference
In-Depth Information
CREATE TABLE speculative_retries_demo (id uuid PRIMARY KEY,
name varchar)
WITH
speculative_retry = '99percentile';
Altering a table
Altering a table is similar to creating one. You can add, rename, change type, drop
columns, and you can also change various table properties that we saw in the previous
section. Let's take a simple table and play with it:
CREATE TABLE modify_me (id uuid PRIMARY KEY, name varchar);
Adding a column
Adding a column has a syntax as follows:
ALTER TABLE table_name ADD new_column_name column_type;
However, you cannot mix a counter column in a non-counter table. Let's take a look at the
following examples:
ALTER TABLE modify_me ADD phone_numbers map <varchar,
varchar>;
ALTER TABLE modify_me ADD count_sheep counter;
<ErrorMessage code=2300 [Query invalid because of
configuration issue] message="Cannot add a counter column
(count_sheep) in a non counter column family">
Renaming a column
Renaming has very limited capability. Cassandra 2.1.0 only allows renaming columns that
are a part of a primary key. The syntax is as follows:
ALTER TABLE table_name RENAME old_name TO new_name;
Search WWH ::




Custom Search