trallallalloo
trallallalloo

Reputation: 602

is it possible to insert json into cassandra without creating table

How can I insert json objects to Cassandra table without creating table? Can Cassandra parse json to table which is not created? Or, Can I create a table with no column and insert json?

Thanks.

Upvotes: 2

Views: 6830

Answers (2)

S. Stas
S. Stas

Reputation: 810

After Cassandra 2.2 you can insert json directly, but the table still should be created beforehead.

Upvotes: 4

Ashraful Islam
Ashraful Islam

Reputation: 12840

You need to create table First, then you can insert data

You can create table like the below one :

CREATE TABLE json_data (
    id timeuuid PRIMARY KEY,
    data text
);

And you can insert the json as string with the below query :

INSERT INTO json_data (id , data ) VALUES ( now(), '{"first_name" : "Ashraful",  "last_name" : "Islam"}') ;

Upvotes: 4

Related Questions