Import and export schema in cassandra

vpggopal picture vpggopal · May 8, 2013 · Viewed 47.7k times · Source

How to import and export schema from Cassandra or Cassandra cqlsh prompt?

Answer

Raman Yelianevich picture Raman Yelianevich · Mar 3, 2015

To export keyspace schema:

cqlsh -e "DESC KEYSPACE user" > user_schema.cql

To export entire database schema:

cqlsh -e "DESC SCHEMA" > db_schema.cql

To import schema open terminal at 'user_schema.cql' ('db_schema.cql') location (or you can specify the full path) and open cqlsh shell. Then use the following command to import keyspace schema:

source 'user_schema.cql'

To import full database schema:

source 'db_schema.cql'