Creating keyspaces and tables with DataStax Studio

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

  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.

    stdCreatingCQLSchema1
    Creating CQL schema 1
  3. Create two tables using the CQL command:

    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 .

    stdCreatingCQLSchema2
    Creating CQL schema 2
  4. Use the CQL shell command to display information about the keyspace that you created:

    DESCRIBE KEYSPACE inventory;
    stdCreatingCQLSchema3
    Creating CQL schema 3

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com