Table in Apache Cassandra

Connect with

Apache Cassandra TableLearn Apache Cassandra table, create table in Cassandra, describe table in cassandra, create table with ID, alter table in cassandra. drop table in cassandra.

1. Create Apache Cassandra Table

Apache Cassandra is very much flexible with different types of data, whether it is either semi-structured data or unstructured data. A keyspace is similar to a schema in RDBMS and the Coulum-family of Apache Cassandra is similar to a table in RDBMS. Most of the time we talk about, Table in Cassandra. Apache Cassandra is very much flexible with different types of data, whether it is either semi-structured data or unstructured data. If you are new in Cassandra, you can visit our post: What is Apache Cassandra?

CREATE TABLE users (
    user_id text PRIMARY KEY,
    emails set
    );

OR

create TABLE user (
   first_name varchar , 
   last_name varchar, 
   PRIMARY KEY (first_name)
   );

2. Creating a table with ID

If a table is accidentally dropped with DROP TABLE command, by using this option you can recreate the table and run a commitlog replay to retrieve the data.

CREATE TABLE users (
    user_id text PRIMARY KEY,
    emails set
    ) WITH ID='5a1c395e-b41f-11e5-9f22-ba0be0483c18';

3. Alter table in Cassandra

Alter of table in cassandra using forllowng example command.

CREATE TABLE user (
  user_name varchar PRIMARY KEY, 
  bio ascii,
  );
ALTER TABLE user ALTER bio TYPE text;
ALTER TABLE user ALTER bio TYPE blob;

Adding a Column

ALTER TABLE user_keyspace.user ADD firstname text;

Drop a Column in Cassandra
Dropping a table in Apache cassandra is very simple. You can drop table with following cammand.

ALTER TABLE user_keyspace.user DROP bio ;

4. Describe Casandra Table

How do you describe in table in cassandra for details of its column and table structure.

DESCRIBE TABLE user;

5. References

  1. Datastax’s cqlsh

Similar Post which you may like

Your Comments are welcome to improve this post.


Connect with

1 thought on “Table in Apache Cassandra”

  1. Pingback: Rajan

Leave a Comment

Your email address will not be published. Required fields are marked *