Skip to content

Cassandra crash course

Jonathan Janetzki edited this page Jul 27, 2017 · 1 revision

Here are some exemplary commands that will help you using the Apache Cassandra database:

  • Connect to the Cassandra Shell: cqlsh <host> -u <user> -p <password> --request-timeout=3600
  • Create a keyspace:
CREATE KEYSPACE wikidumps WITH REPLICATION = {
    'class' : 'SimpleStrategy',
    'replication_factor' : 3
};
  • Use a keyspace: USE wikidumps;
  • Create a type:
CREATE TYPE wikidumps.link (
    alias text,
    page text,
    offset int,
    context map<text, int>,
    article text
);
  • Create a table:
CREATE TABLE wikidumps.parsedwikipedia (
    title text PRIMARY KEY,
    context map<text, int>,
    ...
    text text,
    textlinks list<frozen<link>>
);
  • View the contents of a table: SELECT * FROM parsedwikipedia LIMIT 3;
  • Truncate a table: TRUNCATE parsedwikipedia;
Clone this wiki locally