Search code examples
primary-keycql3cassandra-2.0

Cassandra select on primary key without primary keys name


Using CQL 3 I essentially want to make a statement like so....

SELECT * FROM columnFamilyName WHERE <PK>=1;

Where <PK> is a generic term for primary key.

If i have 2 tables one where the primary key name is ID, and one where it is Index, the above statement should work for both.

In a sense aerospike supports this(the primary key in aerospike simply doesnt have a name), but im not sure how to get the same generic primary key name in cassandra.


Solution

  • Ukemi, I'm not aware of this being possible because a Cassandra table can have a compound primary key and the first part of the primary key can also itself be a compound partition key.

    E.g. in this situation:

    CREATE TABLE .... PRIMARY KEY ((a, b), c, d) ..
    

    Does <PK> refer to a, b, c or d?

    Of course, if it IS possible, I'd like to know too!

    Cheers,