Database Reference
In-Depth Information
Listing 4.11
Example Usage of
INSERT
Specifying a TTL
INSERT INTO events (
event_time,
url,
event_id,
network_location,
event_data
) VALUES (
1365977131666,
'http://www.google.com',
now(),
'10.10.10.10',
'{"browser": "Firefox"}'
) USING TTL 345600;
UPDATE
Just as with the
INSERT
statement, you must specify the
PRIMARY KEY
as part
of the
UPDATE WHERE
statement. In addition, the only other difference is that
in CQL the
UPDATE
command does not check for the existence of the row; if the
row does not exist, CQL will just create it. Because of this, the application can ex-
clusively use
UPDATE
and not have to use
INSERT
when modifying data.
Listing 4.12
Example Usage of
UPDATE
Specifying a TTL
UPDATE events USING TTL 345600
SET event_id=now(),
network_location='10.10.10.10',
event_data='{"browser": "Firefox"}'
WHERE event_time=1365977131666
AND url='http://www.google.com';