Database Reference
In-Depth Information
("username", "id", "body")
VALUES(
'dave',
16e2f240-2afa-11e4-8069-5f98e903bf02,
'dave update 4'
);
INSERT INTO "home_status_updates" (
"timeline_username",
"status_update_id",
"status_update_username",
"body")
VALUES (
'alice',
16e2f240-2afa-11e4-8069-5f98e903bf02,
'dave',
'dave update 4'
);
APPLY BATCH;
This operation has only two possible outcomes: either it's successful, and rows are written
to both
user_status_updates
and
home_status_updates
, or it fails, and no
data is written at all. In either case, our data is consistent.
Note
If you typed the above query into cqlsh, you might have noticed that a new prompt did not
appear until after
APPLY BATCH
. This is because, even though it contains multiple write
statements, a batch must be sent as a single query to Cassandra. This is in contrast to SQL
in which it is valid to open a transaction by sending a
BEGIN TRANSACTION
statement
to the database, and to close it with a later statement.