Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multiple columns in cassandra table?

I need to add some new columns to my existing column_family/table in cassandra. I can add single column like this :

ALTER TABLE keyspace_name.table_name ADD column_name cql_type;

Can I add all new columns using a single query? If yes, how to do it using cql and datastax cassandra driver?

like image 272
Pankaj Goyal Avatar asked Jan 05 '16 08:01

Pankaj Goyal


People also ask

How do you add columns in Cassandra?

You can add a column in the table by using the ALTER command. While adding column, you have to aware that the column name is not conflicting with the existing column names and that the table is not defined with compact storage option. Syntax: ALTER TABLE table name.

How do you update multiple columns in Cassandra?

The UPDATE SET operation is not valid on a primary key field. Specify other column values using SET. To update multiple columns, separate the name-value pairs using commas.

How many columns can Cassandra have?

Cassandra allows 2 billion columns per row.

How do I create a column family in Cassandra?

In Cassandra, create a column family by using the CREATE TABLE command. Create table schema using cqlsh. Define the primary key. Name the table and specify the keyspace that contains its name.


1 Answers

This is fixed in Cassandra 3.6 https://issues.apache.org/jira/browse/CASSANDRA-10411

ALTER TABLE foo ADD (colname1 int, colname2 int)
like image 166
Lucas B Avatar answered Sep 27 '22 19:09

Lucas B