Shalu
Shalu

Reputation: 251

How to add columns dynamically in a column family in cassandra using cql

I want to add columns dynamically to this column family via code using cql.

CREATE COLUMN FAMILY blog_entry
WITH comparator = UTF8Type
AND key_validation_class=UTF8Type
AND default_validation_class = UTF8Type;

how shall I do it?

Upvotes: 10

Views: 22310

Answers (3)

Harish Kumar
Harish Kumar

Reputation: 528

For this to work you have to first alter the table to add column and then insert will start working. I tried the above on cqlsh and it worked.

alter table newdata add column name varchar;

Please refer below link too:

How to define dynamic column families in cassandra

Upvotes: 4

Beyhan Gul
Beyhan Gul

Reputation: 1259

ALTER TABLE blog_entry ADD newcolumnname text;

Upvotes: 0

jbellis
jbellis

Reputation: 19377

This is becoming something of a FAQ, so I wrote an in-depth explanation: http://www.datastax.com/dev/blog/does-cql-support-dynamic-columns-wide-rows

Upvotes: 18

Related Questions