Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Cassandra Alter Table

Cassandra Alter Table for beginners and professionals with topics on architecture, relational vs no sql database, data model, cql, cqlsh, keyspace operations, table operations, installation, collections etc.

<< Back to CASSANDRA

Cassandra Alter Table

ALTER TABLE command is used to alter the table after creating it. You can use the ALTER command to perform two types of operations:

  • Add a column
  • Drop a column


ALTER (TABLE | COLUMNFAMILY) <tablename> <instruction> 

Adding a Column

You can add a column in the table by using the ALTER command. While adding column, you have to aware that the column name is not conflicting with the existing column names and that the table is not defined with compact storage option.


ALTER TABLE table name
ADD new column datatype; 


Let's take an example to demonstrate the ALTER command on the already created table named "student". Here we are adding a column called student_email of text datatype to the table named student.

Prior table:

Cassandra Alter table 1

After using the following command:

ADD student_email text;
Cassandra Alter table 2

A new column is added. You can check it by using the SELECT command.

Cassandra Alter table 3

Dropping a Column

You can also drop an existing column from a table by using ALTER command. You should check that the table is not defined with compact storage option before dropping a column from a table.


ALTER table name
DROP column name; 


Let's take an example to drop a column named student_email from a table named student.

Prior table:

Cassandra Alter table 4

After using the following command:

ALTER TABLE student 
DROP student_email; 
Cassandra Alter table 5

Now you can see that a column named "student_email" is dropped now.

If you want to drop the multiple columns, separate the columns name by ",".

See this example:

Here we will drop two columns student_fees and student_phone.

DROP (student_fees, student_phone);


Cassandra Alter table 6

Related Links:

Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf