Create, Alter and Drop Table Cassandra

Table in Cassandra is a collection of ordered (by name) columns fetched by row. A row consists of columns and have a primary key. The first part of the key is a column name. Subsequent parts of a compound key are other column names that define the order of columns in the table.


Example Create Table

To check the table using desc table_name;

Defined Table with Columns Collection Data Type

Cassandra is a NoSql database support column with collection type.
This is example table with include collection type

To Check tables using desc tables;

Create table with tupple-type

Tuple data type that holds fixed-length sets of typed positional fields. You can use a tuple as an alternative to a user-defined type when you don’t need to add new fields. A tuple can accommodate many fields (32768).
In the table creation statement, use angle brackets and a comma delimiter to declare the tuple component types. Surround tuple values in parentheses to insert the values into a table, as shown in this example.

before searching data on tuple datatype you must create index on tuples column
create index on customer_tuples(address);

Modifying Column Table

  • Add Column

  • Change Datatype of columns(Not Support Again error_code=2200)

  • Drop Column

  • RENAME PRIMARY KEY column (only primary key)

Drop Table Cassandra

DROP TABLE statement results in the immediate, irreversible removal of a table, including all data contained in the table

Happy Coding and Learning.
Happy New Years 2018…