Creating keyspaces and tables with DataStax Studio

Steps to add CQL code to a notebook to create a simple keyspace and two tables.

Prerequisites

Add CQL code to a notebook to create a simple keyspace and two tables.

Procedure

  1. Open a notebook.
  2. Create a DSE keyspace using the CQL command CREATE KEYSPACE:
    CREATE KEYSPACE inventory WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
    1. Select CQL select as the language.
    2. No keyspace is selected, as none currently exists.
    3. Click the button labelled CL.ONE to execute the CQL code.
  3. Create two tables using the CQL command CREATE TABLE:
    USE inventory;  //or select the default keyspace above, and comment out this line
    
    CREATE TABLE product_info (
       product_id uuid,
       product_name varchar,
       PRIMARY KEY (product_id)
    ); 
    CREATE TABLE buyer_info (
       buyer_id uuid,
       buyer_name varchar,
       PRIMARY KEY (buyer_id)
    );
    The keyspace can be configured using the Keyspace pull-down menu in the cell, or with the CQL command USE.
  4. Use the CQL shell command DESCRIBE KEYSPACE to display information about the keyspace that you created:
    DESCRIBE KEYSPACE inventory;