Adds or updates one or more columns in the identified row of a table.
INSERT INTO keyspace_name.table_name ( identifier, identifier...) VALUES ( value, value ... ) USING option AND option
identifier is a column or a collection name.
Value is one of:
a column value
a set:
{ item1, item2, . . . }
a list:
[ name, value ]
a map:
{ name : value, name : value, . . . }
option is one of:
An INSERT writes one or more columns to a record in a Cassandra table atomically and in isolation. No results are returned. You do not have to define all columns, except those that make up the key. Missing columns occupy no space on disk.
If the column exists, it is updated. You can qualify table names by keyspace. INSERT does not support counters, but UPDATE does.
INSERT INTO playlists (id, song_id, title, artist, album) VALUES (62c36092-82a1-3a00-93d1-46196ee77204, a3e64f8f-bd44-4f28-b8d9-6938726e34d4, 'La Grange', 'ZZ Top', 'Tres Hombres'); INSERT INTO playlists (id, song_id, title, artist, album) VALUES (62c36092-82a1-3a00-93d1-46196ee77204, 8a172618-b121-4136-bb10-f665cfc469eb, 'Moving in Stereo', 'Fu Manchu', 'We Must Obey'); INSERT INTO playlists (id, song_id, title, artist, album) VALUES (62c36092-82a1-3a00-93d1-46196ee77204, 2b09185b-fb5a-4734-9b56-49077de9edbf, 'Outside Woman Blues', 'Back Door Slam', 'Roll Away');
You can specify one or more of these options after the USING keyword:
INSERT INTO Hollywood.NerdMovies (user_uuid, fan) VALUES (cfd66ccc-d857-4e90-b1e5-df98a3d40cd6, 'johndoe') USING TTL 86400;
TTL input is in seconds. TTL column values are automatically marked as deleted (with a tombstone) after the requested amount of time has expired. TTL marks the inserted values, not the column itself, for expiration. Any subsequent update of the column resets the TTL to the TTL specified in the update. By default, values never expire.
The TIMESTAMP input is in one of the following formats:
If not specified, the time (in microseconds) that the write occurred to the column is used.
To insert data into the set, enclose values in curly brackets. Set values must be unique. For example:
INSERT INTO users (user_id, first_name, last_name, emails)
VALUES('frodo', 'Frodo', 'Baggins', {'f@baggins.com', 'baggins@gmail.com'});
Insert a map named todo to insert a reminder, 'die' on October 2 for user frodo.
INSERT INTO users (user_id, todo )
VALUES('frodo', {'2012-10-2 12:10' : 'die' } );