Reputation: 11
Instead of hard cording schema, I am trying to build using Cassandra API. My schema is
"CREATE KEYSPACE IF NOT EXISTS"
Example, for creating table we are using
SchemaBuilder.createTable(tableName).ifNotExists();
Same way how to create 'KEYSPACE'?
I am using Cassandra 3.x version.
Please help me.
Upvotes: 1
Views: 503
Reputation: 939
The com.datastax.oss.driver.api.querybuilder.SchemaBuilder
API provides SchemaBuilder.createTable("<keyspace>", "<tableName>")
in one shot.
Upvotes: 1
Reputation: 762
You can do
SchemaBuilder.createKeyspace(keyspaceName).ifNotExists()
Upvotes: 0