Database Reference
In-Depth Information
Syntactic sugar for deletion
Although Cassandra doesn't have real NULL columns, CQL does provide some syntactic
sugar to provide a more familiar interface to remove data from columns. You can, in fact,
write UPDATE statements that set values to null :
UPDATE "users"
SET "location" = NULL
WHERE "username" = 'alice';
Note that this is purely syntactic sugar: the preceding statement is precisely the same opera-
tion as the following one:
DELETE "location"
FROM "users"
WHERE "username" = 'alice';
The DELETE form of the statement is more expressive of what we are actually do-
ing—removing a value from a column—but the UPDATE form is more familiar for anyone
used to working with with SQL. Another advantage of the UPDATE statement is that we
can write a statement that simultaneously sets data in some columns, and removes data
from others:
UPDATE "users"
SET "email" = 'carol@hotmail.com', "location" = NULL
WHERE username = 'carol';
Checking up on the status of the users table, we can see that carol 's row reflects our
latest changes:
Search WWH ::




Custom Search