Add Column to Existing Table in Cassandra by using CQL
It is very easy to add new column/s to existing table in Cassandra.
Syntax:
You can see that I am already in TechBrothersTutorials keyspace. You can "Use Keyspace" to change to keyspace where your table is before running Alter table statement or you can use Full qualified name.
Example:
Let's create Employee table with below definition and then we will use Alter statment to add "PhoneNumber" column.
(
employeeid UUID PRIMARY KEY,
fname TEXT,
lname TEXT,
address TEXT,
age TINYINT
);
Add PhoneNumber column to Employee table.
Note that the newly added column will have Null values for exiting records. You can verify the definition of table has change correctly by using Describe Table statement.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.