Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.


Cql – cassandra query language Slide 1 Cql – cassandra query language Slide 2 Cql – cassandra query language Slide 3 Cql – cassandra query language Slide 4 Cql – cassandra query language Slide 5 Cql – cassandra query language Slide 6 Cql – cassandra query language Slide 7 Cql – cassandra query language Slide 8 Cql – cassandra query language Slide 9 Cql – cassandra query language Slide 10 Cql – cassandra query language Slide 11 Cql – cassandra query language Slide 12
Upcoming SlideShare
Introduction to cassandra
Download to read offline and view in fullscreen.



Download to read offline

Cql – cassandra query language

Download to read offline

Introduction to CQL v1.0.0

Related Books

Free with a 30 day trial from Scribd

See all

Cql – cassandra query language

  1. 1. CQL – Cassandra Query Language<br />Courtney Robinson – Eric Evans (Python tests and CQL Spec)<br />
  2. 2. Thrift or Avro?<br />External dependency<br />Community activity dissipates<br />Too generic<br />Many user reported problems caused by Thrift or the misuse thereof...<br />Its thrift! Its Avro!<br />Its CQL....<br />
  3. 3. What is it?<br />Effectively a structured query language<br />Replacement for clients? Not really...<br />Attempting to push as much server-side as possible<br />Familiar syntax<br />User friendly API for Cassandra new comers<br />
  4. 4. CQL V1.0.0 - Keywords<br />USE<br />SELECT<br />UPDATE<br />DELETE<br />TRUNCATE<br />DROP<br />BATCH<br />CREATE KEYSPACE<br />CREATE COLUMNFAMILY<br />CREATE INDEX<br />That’s right!No INSERT...?<br />Special statements<br />
  5. 5. Specifying Consistency<br />... USING <CONSISTENCY> ... <br />Made up of the keyword USING, followed by a consistency level identifier.<br />Valid consistency levels are:<br />CONSISTENCY ZERO<br />CONSISTENCY ONE (default)<br />CONSISTENCY QUORUM<br />CONSISTENCY ALL<br />CONSISTENCY DCQUORUM<br />CONSISTENCY DCQUORUMSYNC<br />E.gBEGIN BATCH USING CONSISTENCY ONE<br />
  6. 6. Create keyspce<br />CREATE KEYSPACE WITH replication_factor = AND strategy_class = [AND strategy_options. = [AND strategy_options. = ]];<br />E.gCREATE KEYSPACE TestKeyspaceWITH strategy_options:DC1 = '1‘ AND strategy_class = 'NetworkTopologyStrategy‘<br />CREATE COLUMNFAMILY [(name1 type, name2 type, ...)] [WITH keyword1 = arg1 [AND keyword2 = arg2 [AND ...]]];<br />Set column type:<br />CREATE COLUMNFAMILY (name1 type, name2 type) ...; <br />CREATE INDEX [index_name] ON <column_family> (column_name); <br />Used to create a new, automatic secondary index for the named column.<br />Create Column Family<br />Create INDEX<br />
  7. 7. USE<br />USE <KEYSPACE>;<br />Use keyword followed by a valid Keyspace name<br />Set working Keyspace per-connection<br />DROP <KEYSPACE|COLUMNFAMILY>;<br />DROP KEYSPACE KSName;<br />DROP COLUMNFAMILYCFName; Immediate, irreversible removal of keyspace and column family namespaces.<br />TRUNCATE <COLUMN FAMILY> <br />Accepts a single argument (CF) name<br />permanently removes all data from said column family.<br />DROP<br />TRUNCATE<br />
  8. 8. UPDATE (values)<br />UPDATE [USING CONSISTENCY ] SET name1 = value1, name2 = value2 WHERE KEY = keyname;<br />UPDATE is used to write one or more columns to a record in a Cassandra column family. <br />No results are returned.<br />Creates or updates rows<br />UPDATE CFName SET ‘name' = 10 WHERE KEY = ‘1234’<br />UPDATE <COLUMN FAMILY> ...<br />Begin with the UPDATE keyword followed by CF name.<br />Followed by an optional consistency level specification.<br />
  9. 9. BATCH UPDATES<br />Where’s my batch mutate gone?<br />Similar to code blocks/structs<br />Has begining (Begin Batch) and end (Apply Batch)<br />BEGIN BATCH [USING ] <br />UPDATE CF1 SET name1 = value1, name2 = value2 WHERE KEY = keyname1;<br />UPDATE CF1 SET name3 = value3 WHERE KEY = keyname2; <br />UPDATE CF2 SET name4 = value4, name5 = value5 WHERE KEY = keyname3; <br />APPLY BATCH<br />BEGIN BATCH USING CONSISTENCY QUORUM<br />UPDATE CFnameSET 1='1', 2='2', 3='3', 4='4' WHERE KEY='aa‘<br />UPDATE CFname2 SET 5='5', 6='6', 7='8', 9='9' WHERE KEY='ab'<br />UPDATE CFnameSET 9='9', 8='8', 7='7', 6='6' WHERE KEY='ac'<br />UPDATE CFname3 SET 5='5', 4='4', 3='3', 2='2' WHERE KEY='ad'<br />UPDATE CFnameSET 1='1', 2='2', 3='3', 4='4' WHERE KEY='ae'<br />APPLY BATCH<br />
  10. 10. DELETE<br />DELETE [COLUMNS] FROM [USING ] WHERE KEY = keyname1 <br />DELETE [COLUMNS] FROM [USING ] WHERE KEY IN (keyname1, keyname2);<br /><ul><li> Remove one or more columns from one or more rows.
  11. 11. Optional comma-delimited list of column names following DELETE
  12. 12. Removes entire row(s) if no columns are specified
  13. 13. DELETE ‘col1', 'col2' FROM CF WHERE KEY = 'key‘
  14. 14. DELETE ‘col1', 'col2' FROM CF WHERE KEY = ('key‘, ‘key2’, ‘key3’)</li></li></ul><li>SELECT<br />SELECT [FIRST N] [REVERSED] <SELECT EXPR> FROM <COLUMN FAMILY> [USING <CONSISTENCY>] [WHERE <CLAUSE>] [LIMIT N];<br />FIRST = number of columns, N<br />REVERSED = Reverses sort order<br />Return a result set, key + columns per row<br />Specify columns:<br />SELECT [FIRST N] [REVERSED] name1, name2, name3 FROM ... <br />Request a range of columns:<br /> SELECT [FIRST N] [REVERSED] name1..nameN FROM ... <br />“..” Notation specifies range <br />Inclusive of start and end columns<br />E.gSELECT FIRST 2 REVERSED 3..1 FROM CF WHERE KEY = 'aa'<br />
  15. 15. Courtney Robinson @zcourts<br />Thank you for listening.<br />Questions?Links:<br /><br /><br /><br />
  • HeggyY

    Mar. 4, 2016
  • eceseenu1989

    Jul. 11, 2013
  • satymatos

    May. 24, 2013
  • FGRibreau

    Sep. 13, 2012
  • KotaWakamoto

    Nov. 22, 2011
  • yutuki

    Jun. 8, 2011

Introduction to CQL v1.0.0


Total views


On Slideshare


From embeds


Number of embeds