tet
tet

Reputation: 1407

Is it possible to delete all rows for a specific column at once in cassandra?

This is not a question asking how to delete all data for a table. That's what TRUNCATE does.

I want to delete all rows for a specific column at once in cassandra. I can delete only one row for a specific column using DELETE or UPDATE like the follows.

DELETE column_name FROM table_name WHERE primary_key = value_of_primary_key;

or

UPDATE table_name SET column_name = null WHERE primary_key = value_of_primary_key;

However, what I want to do is like the follows.

TRUNCATE key_name.table_name.column_name;

The above TRUNCATE code doesn't work since it doesn't take column_name, but I hope you understand what I want to do.

Is it possible to delete all rows for a specific column at once?

If so, how can I do that?

If not, what is the best workaround for this?

Upvotes: 0

Views: 160

Answers (1)

Ashraful Islam
Ashraful Islam

Reputation: 12830

Try Drop the column and Add the column again.

Example :

ALTER TABLE table_name DROP column_name;
ALTER TABLE table_name ADD column_name text;

Upvotes: 2

Related Questions