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
?
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.
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.
Cassandra allows 2 billion columns per row.
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.
This is fixed in Cassandra 3.6 https://issues.apache.org/jira/browse/CASSANDRA-10411
ALTER TABLE foo ADD (colname1 int, colname2 int)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With