Create Table in Cassandra

Cassandra Create Table
To create a table, the CREATE TABLE command is used in Cassandra. In Cassandra, a column family works just like a table in RDBMS, thus a column family is created in Cassandra, instead of a table.

Syntax 1:

CREATE (TABLE | COLUMNFAMILY)   
('' , '')  
(WITH 

Syntax 2: Declaring a primary key:

CREATE TABLE table_name(  
Column_Name1 Data_Type PRIMARY KEY,  
Column_Name2 Data_Type,  
Column_Name3 Data_Type  ... )  

Syntax 3: Declaring a primary key:

CREATE TABLE table_name(  
Column_Name1 Data_Type,  
Column_Name2 Data_Type,  
Column_Name3 Data_Type  
...
Primary key(Column_Name)  ) 
with Property_Name=Property_Value;   

Types of primary keys:

Single primary key:
Syntax:

Primary key (Column_Name)   

Compound primary key:
Syntax:

Primary key(Column_Name1,Column_Name2 . . .)    

Example:

CREATE TABLE employees(  
   id int PRIMARY KEY,  
   name text,    
   salary varint
   );

Explanation:
A table named ’employees’ is created. The created table can be checked using the below command.

SELECT * FROM employees;

Output:

id	name	salary