cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Mechler <rmech...@sencha.com>
Subject DELETE from table with composite keys
Date Mon, 14 May 2012 17:18:48 GMT
I have a table with a 3 part composite key and I want to delete rows based
on the first 2 parts of the key. SELECT works using 2 parts of the key, but
DELETE fails with the error:

    Bad Request: Missing mandatory PRIMARY KEY part part3

(see details below). Is there a reason why deleting based on the first 2
parts should not work? I.e., is it just currently not supported, or is it a
permanent limitation?

Note that deleting based on just the first part of the key will work…
deletes all matching rows.

cqlsh:Keyspace1> CREATE TABLE MyTable (part1 text, part2 text, part3 text,
data text, PRIMARY KEY(part1, part2, part3));
cqlsh:Keyspace1> INSERT INTO MyTable (part1, part2, part3, data) VALUES
(‘a’, ‘b’, ‘c’, ‘d’);
cqlsh:Keyspace1> SELECT * FROM MyTable WHERE part1 = ‘a’ AND part2 = ‘b’;
part1 | part2 | part3 | data
——-+——-+——-+——
a | b | c | d

cqlsh:Keyspace1> DELETE FROM MyTable WHERE part1 = ‘a’ AND part2 = ‘b’;
Bad Request: Missing mandatory PRIMARY KEY part part3
cqlsh:Keyspace1> DELETE data FROM MyTable WHERE part1 = ‘a’ AND part2 = ‘b’;
Bad Request: Missing mandatory PRIMARY KEY part part3
cqlsh:Keyspace1> DELETE FROM MyTable WHERE part1 = ‘a’;
cqlsh:Keyspace1> SELECT * FROM MyTable WHERE part1 = ‘a’ AND part2 = ‘b’;
cqlsh:Keyspace1>

-Roland

Mime
View raw message