Altering a table

Tables can be changed with the ALTER statement, using it to add a column:

ALTER TABLE query_test ADD c6 TEXT;

Or to remove a column:

ALTER TABLE query_test DROP c5;
Primary key definitions cannot be changed on a table. To accomplish this, the table must be recreated.

Table options can also be set or changed with the ALTER statement. For example, this statement updates the default TTL on a table to one day (in seconds):

ALTER TABLE query_test WITH default_time_to_live = 86400;

Get Mastering Apache Cassandra 3.x - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.