Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import and export schema in cassandra

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

like image 213
vpggopal Avatar asked May 08 '13 12:05

vpggopal


2 Answers

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' 
like image 56
Raman Yelianevich Avatar answered Sep 28 '22 06:09

Raman Yelianevich


Everything straight from the command line. No need to go into cqlsh.

Import schema (.cql file):

$ cqlsh -e "SOURCE '/path/to/schema.cql'" 

Export keyspace:

$ cqlsh -e "DESCRIBE KEYSPACE somekeyspace" > /path/to/somekeyspace.cql 

Export database schema:

$ cqlsh -e "DESCRIBE SCHEMA" > /path/to/schema.cql 
like image 45
rouble Avatar answered Sep 28 '22 05:09

rouble