Alter columns

Use the ALTER TABLE command to add new columns, drop non-primary key columns, or rename a primary key column.

To change the table settings, see Alter table properties.

This command requires a keyspace and a table with defined columns.

Add a column

The ALTER TABLE command creates the column metadata, adds the column to the table schema, and sets the value to null for all rows.

The following example adds an integer column named age to the table cycling.cyclist_alt_stats:

ALTER TABLE cycling.cyclist_alt_stats ADD cyclist_age int;

You can add any type of column.

This example adds a map collection column named description to store a name and description for each race in the cycling.upcoming_calendar table:

ALTER TABLE cycling.upcoming_calendar 
  ADD description map<text,text>;

Rename a column

Only primary key columns can be renamed. If you need to rename another column, you must drop and recreate the column.

This example renames the id primary key column to cyclist_id:

ALTER TABLE cycling.cyclist_alt_stats RENAME id TO cyclist_id;

Drop a column

You can use ALTER TABLE to drop (delete) a column from a table.

The column and all of it’s data are deleted. If you need to preserve the data, take action to extract the data before you drop the column.

ALTER TABLE cycling.cyclist_alt_stats DROP cyclist_age;

Verify schema changes

To verify that a column was added, renamed, or removed, use SELECT or DESCRIBE TABLE commands, as explained in Check column existence.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2025 DataStax, an IBM Company | Privacy policy | Terms of use | Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com