Prepare for the Cassandra certification. Use flashcards, multiple-choice questions with explanations to help you master the subject. Gear up for your Cassandra exam!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


Which of the following is a valid SQL command to create a table in Cassandra?

  1. Create Table table1 (col1 STRING, col2 INT);

  2. Create table1 (col1 TEXT, col2 INT, PRIMARY KEY (col1));

  3. Create Table table1 (col1 TEXT, col2 INT, col3 INT, PRIMARY KEY (col1));

  4. Create Table (col1 TEXT, col2 INT);

The correct answer is: Create Table table1 (col1 TEXT, col2 INT, col3 INT, PRIMARY KEY (col1));

The command presented in the correct choice provides a valid syntax for creating a table in Cassandra. In Cassandra, the structure for creating a table requires specifying the table name along with the columns and their data types, followed by the primary key. In this instance, "Create Table table1" indicates that a table named "table1" is being created. Subsequently, the command outlines the columns "col1," "col2," and "col3" along with their respective data types (TEXT for "col1" and INT for "col2" and "col3"). The inclusion of "PRIMARY KEY (col1)" designates "col1" as the primary key for the table, which is crucial for Cassandra as it uses this key to partition data across the nodes in the cluster. The command is structured correctly, matching Cassandra’s requirements for table creation, making it a valid SQL command in the context of Cassandra. In contrast, options that lack the correct syntax or structural components would fail to be valid commands. For instance, omitting the table name or incorrectly specifying the primary key would lead to errors, failing to adhere to the language's syntactical rules. Each aspect of the correct choice aligns with Cassandra's requirements and conventions for table creation