Reputation: 8773
I am trying to create a user defined type with Cassandra. I am using cqlsh
and the example provided in the documentation (http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/cqlRefcreateType.html):
REATE TYPE address (
street text,
city text,
zip_code int,
phones set<text>
)
But this returns:
Bad Request: line 1:7 no viable alternative at input 'TYPE'
Using the help
command, I found the 'CREATE_TABLE_TYPES' but I could not get it to work either.
What is the correcft syntax to get this to work?
Many thanks
Upvotes: 0
Views: 1730
Reputation: 1122
I also struck with same problem. User type doesn't supported by earlier version of 2.1
.
Now i am using 2.1.2
version of cassandra
.
You can find it NEW FEATURES of Cassandra
Upvotes: 0
Reputation: 2283
Looks like you need to create a keyspace first:
cqlsh> CREATE KEYSPACE excelsior
... WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
cqlsh> use excelsior;
cqlsh:excelsior> CREATE TYPE address (
... street text,
... city text,
... zip_code int,
... phones set<text>
... );
Upvotes: 1