CQL for Cassandra 2.0

Altering the data type of a column

Using ALTER TABLE, you can change the data type of a column after it is defined or added to a table.

Procedure

Change the coupon_code column to store coupon codes as integers instead of text by changing the data type of the column.
cqlsh:demodb> ALTER TABLE users ALTER coupon_code TYPE int;
Only newly inserted values, not existing coupon codes are validated against the new type.
Show/hide