user374374
user374374

Reputation: 343

Datastax rename table

I have deployed 9 node cluster on google cloud.

Created a table and loaded the data. Now want to change the table name.

Is there any way I can change the table name in Cassandra?

Thanks

Upvotes: 1

Views: 8757

Answers (1)

Ashraful Islam
Ashraful Islam

Reputation: 12840

You can't rename table name.
You have to drop the table and create again

You can use ALTER TABLE to manipulate the table metadata. Do this to change the datatype of a columns, add new columns, drop existing columns, and change table properties. The command returns no results.

Start the command with the keywords ALTER TABLE, followed by the table name, followed by the instruction: ALTER. ADD, DROP, RENAME, or WITH. See the following sections for the information each instruction require

If you need the data you can backup and restore data using copy command in cqlsh.

To Backup data :

COPY old_table_name TO 'data.csv'

To Restore data :

COPY new_table_name FROM 'data.csv'

Upvotes: 6

Related Questions