5

I am using cassandra 1.2.15 version. Using cassandra CQL Java driver I will be creating a keyspace. My problem is I can't able to create a keyspace which contains hyphen (test-hyphen).

Code:

String query = "CREATE KEYSPACE \"test-hyphen\" WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor' : 1 }"
resultSet = session.execute(query)

When I tried to do so I am getting following exception:

java.lang.Exception: com.datastax.driver.core.exceptions.InvalidQueryException: "test-hyphen" is not a valid keyspace name

Any work around or any possible way to create keyspace with hyphen in between the characters?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Jaya Ananthram
  • 3,433
  • 1
  • 22
  • 37
  • 1
    Why do you insist on having a hyphen in the keyspace name when Cassandra tells you quite clearly that it's not allowed? You could use an underscore instead of a hyphen: `test_hypen` – Jesper Apr 10 '15 at 19:41

1 Answers1

7

This cannot be done.

From the documentation:

Keyspace names are 32 or fewer alpha-numeric characters and underscores, the first of which is an alpha character. Keyspace names are case-insensitive. To make a name case-sensitive, enclose it in double quotation marks.

Community
  • 1
  • 1
durron597
  • 31,968
  • 17
  • 99
  • 158