Creating keyspaces and tables with DataStax Studio
Steps to add CQL code to a notebook to create a simple keyspace and two tables.
Prerequisites
- DSE 5.1 installed, configured, and running.
- DataStax Studio installed and running.
- A connection from Studio to a DSE cluster.
- An existing notebook.
Add CQL code to a notebook to create a simple keyspace and two tables.
Procedure
- Open a notebook.
-
Create a DSE keyspace using the CQL command CREATE KEYSPACE:
CREATE KEYSPACE inventory WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
- Select CQL select as the language.
- No keyspace is selected, as none currently exists.
-
Click the button labelled
CL.ONE
to execute the CQL code.
-
Create two tables using the CQL command CREATE TABLE:
The keyspace can be configured using the Keyspace pull-down menu in the cell, or with the CQL command USE.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) );
-
Use the CQL shell command DESCRIBE KEYSPACE to display
information about the keyspace that you created:
DESCRIBE KEYSPACE inventory;