Import and export keyspace or schema in cassandra

This command line will export a keyspace from Cassandra:

cqlsh -e "DESCRIBE KEYSPACE test" > /your/path/test.cql

this one will export a schema from Cassandra:

cqlsh -e "DESCRIBE SCHEMA" > /your/path/schema.cql

Then, you can import it with:

cqlsh -e "SOURCE /your/path/test.cql"

cqlsh -e "SOURCE /your/path/schema.cql"

You can also open the terminal in the location of cql file and then open cqlsh shell. Therefore, it is not necessary to write all path:

cd /your/path
cqlsh -e "SOURCE test.cql"

Originally published at Adrià Galín.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store