INSERT JSON

The INSERT statement accepts a JSON variant. Suppose we want to insert some JSON data into our user_status_updates_by_datetime table, we can do it in the following way:

INSERT INTO "user_status_updates_by_datetime"JSON '{"username": "alice", "status_date": "2016-11-24", "status_time":"13:35:20.123456", "body": "Alice Update 7"}';

Now, if you run the query SELECT * FROM "user_status_updates_by_datetime"; you will get the new column that you added using the JSON variant of INSERT as well:

The JSON-encoded map is simply a CQL string literal that is a JSON encoding of a map, where keys are column names and values are column values. ...

Get Learning Apache Cassandra - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.