Questions tagged [cql]

CQL (Cassandra Query Language) is used to interact with and query Cassandra tables. Its syntax is similar to SQL, helping to lower the learning curve to working with Cassandra. For the Cypher graph query language, use the cypher tag.

CQL (Cassandra Query Language) is used to interact with and query Cassandra tables. Its syntax is similar to SQL, helping to lower the learning curve to working with Cassandra. Despite their similarities, in many cases CQL behaves very differently from SQL, so it is important to read the documentation before going too far.

Some of the more useful links to documentation on CQL:

1953 questions
582
votes
8 answers

Difference between partition key, composite key and clustering key in Cassandra?

I have been reading articles around the net to understand the differences between the following key types. But it just seems hard for me to grasp. Examples will definitely help make understanding better. primary key, partition key, composite key…
brain storm
  • 25,842
  • 54
  • 187
  • 349
90
votes
1 answer

Deleting all rows from Cassandra cql table

Is there a command to all the rows present in a cql table in cassandra like the one in sql? delete from TABLE Going by the documentation, I don't find any way to perform delete operation without a where condition. DELETE col1 FROM SomeTable WHERE…
Aarish Ramesh
  • 5,321
  • 10
  • 49
  • 97
61
votes
3 answers

How to get current timestamp with CQL while using Command Line?

I am trying to insert into my CQL table from the command line. I am able to insert everything. But I am wondering if I have a timestamp column, then how can I insert into timestamp column from the command line? Basically, I want to insert current…
user2467545
60
votes
4 answers

How to run cql files (.cql) from within cqlsh?

The problem that I am having is that I want to run the following command (and I can't): cqlsh < cql_directory/cql_create_stuff.cql Because I have not logged in to cqlsh. So I logged in: cqlsh -u 'my_username' -p 'my_super_secret_password' and now…
Charlie Parker
  • 13,522
  • 35
  • 118
  • 206
52
votes
3 answers

Cassandra UUID vs TimeUUID benefits and disadvantages

Given that TimeUUID handily allows you to use now() in CQL, are there any reasons you wouldn't just go ahead and always use TimeUUID instead of plain old UUID?
Jay
  • 17,766
  • 32
  • 110
  • 167
50
votes
2 answers

Inserting a hard-coded UUID via CQLsh (Cassandra)

Would like to populate some static test data via a CQLsh script. This doesn't work: (device_id is UUID) insert into devices (device_id, geohash,name, external_identifier, measures, tags) values ('c37d661d-7e61-49ea-96a5-68c34e83db3a','9q9p3yyrn1',…
Chris H
  • 665
  • 1
  • 6
  • 10
49
votes
4 answers

How to auto generate uuid in cassandra CQL 3 command line

Just learning cassandra, is there a way to insert a UUID using CQL, ie create table stuff (uid uuid primary key, name varchar); insert into stuff (name) values('my name'); // fails insert into stuff (uid, name) values(1, 'my name'); // fails Can…
Jay
  • 17,766
  • 32
  • 110
  • 167
47
votes
4 answers

Is there a clear equivalent of 'show keyspaces' in cqlsh 2?

What cqlsh command can I use to quickly see the keyspaces in a cluster? cqlsh does not provide show keyspaces and describe cluster isn't as concise as I want. I'm working using the following specifications: cqlsh 2.2.0, Cassandra 1.1.10, CQL spec…
Crowie
  • 2,879
  • 6
  • 26
  • 48
46
votes
4 answers

Difference between UPDATE and INSERT in Cassandra?

What is the difference between UPDATE and INSERT when executing CQL against Cassandra? It looks like there used to be no difference, but now the documentation says that INSERT does not support counters while UPDATE does. Is there a "preferred"…
Chris Dutrow
  • 42,732
  • 59
  • 174
  • 243
45
votes
3 answers

Does an UPDATE become an implied INSERT

For Cassandra, do UPDATEs become an implied INSERT if the selected row does not exist? That is, if I say UPDATE users SET name = "Raedwald" WHERE id = 545127 and id is the PRIMARY KEY of the users table, and the table has no row with a key of…
Raedwald
  • 40,290
  • 35
  • 127
  • 207
42
votes
2 answers

How do secondary indexes work in Cassandra?

Suppose I have a column family: CREATE TABLE update_audit ( scopeid bigint, formid bigint, time timestamp, record_link_id bigint, ipaddress text, user_zuid bigint, value text, PRIMARY KEY ((scopeid, formid), time) ) WITH CLUSTERING…
Aftab
  • 766
  • 1
  • 7
  • 19
35
votes
6 answers

Results pagination in Cassandra (CQL)

I am wondering how can I achieve pagination using Cassandra. Let us say that I have a blog. The blog lists max 10 posts per page. To access next posts a user must click on pagination menu to access page 2 (posts 11-20), page 3 (posts 21-30),…
kazy
  • 973
  • 2
  • 11
  • 24
33
votes
1 answer

Check CQL version with Cassandra and cqlsh?

How do you check which cql version is currently being used in cqlsh? In sql, you do this: Select @@version
AturSams
  • 6,416
  • 14
  • 53
  • 91
32
votes
3 answers

cassandra get all records in time range

I have to work with a column family that has (user_id, timestamp) as key. In my query I would like to fetch all records in a given time range independent of the user_id. This is the exact table schema: CREATE TABLE userlog ( user_id text, ts…
Faber
  • 1,268
  • 2
  • 12
  • 19
31
votes
3 answers

How to do a join queries with 2 or more tables in cassandra cql

I am new to cassandra. Here I have two tables EVENTS and TOWER. I need to join those for some queries. But I'm not enable to do it. Structure of EVENTS table: eid int PRIMARY KEY, a_end_tow_id text, a_home_circle text, a_home_operator text, a_imei…
BlueShark
  • 387
  • 3
  • 7
  • 14
1
2 3
99 100