Database Reference
In-Depth Information
Adding columns to tables
Let's say we want to allow our users to enter their location in the profile. To store users'
location, we need a new column in the
users
table; fortunately, it's perfectly straightfor-
ward to add a new column to an existing table:
ALTER TABLE "users" ADD "city_state" text;
This query instructs Cassandra that we'd like to add a column named
city_state
, of
type
text
, to the
users
table. It's identical to the equivalent operation in SQL, although
the CQL
ALTER TABLE
statement is much more constrained in the operations it can per-
form.
Now let's check our table schema again:
DESCRIBE TABLE "users";
As we hoped, we've got a
city_state
column in the schema. I've omitted the table
properties for brevity: