Simple Cassandra Tips
Run cql on a cassandra pod
. Attach to a running pod using bash
. cqlsh -u
What are the names of all my datacenters?
use system;
select data_center from local;
How do you use ORDER BY in Cassandra?
You will need to add the ORDER BY
to your query.
Example Query
SELECT *
FROM chats
ORDER BY message_timestamp
If you use this query and get this error message:
Error from server: code=2200 [Invalid query] message="Order by is currently only supported on the clustered columns of the PRIMARY KEY, got message_timestamp"
This means you need to make sure message_timestamp
is part of your primary key or a clustered column.
if it is in your primary key and you are still getting this message, you probably have a primary key with multiple keys.
Which means you will need to add a WHERE
clause.
SELECT *
FROM chats
WHERE CHAT_ID=123
ORDER BY message_timestamp