Skip to content
Related Articles

Related Articles

Improve Article

Modifying a user-defined type (UDT)

  • Last Updated : 19 Dec, 2019

Pre-requisite – Overview of User Defined Type
In this article, we will discuss how we can change the UDT column and also we can add, Rename the existing column in User Defined Type. So, let’s have a look.

Now, first, we are going to create a UDT table and then we will modify it as per need. So let’s consider Electricity_bill is a table name.

CREATE TYPE Electricity_bill
 (
  Bill_id int,
  Due_date date,
  Submit_date date
 ); 

Now, let’s verify the user-defined type by using the following CQL query given below.

DESCRIBE TYPE Electricity_bill; 

Output:



To add a new column in the user-defined type used the following CQL query.

ALTER TYPE cluster1.Electricity_bill
ADD name text; 

Output:

DESCRIBE TYPE Electricity_bill; 

To rename the existing field ‘RENAME’ keyword can be used. Let’s have a look.

ALTER TYPE cluster1.Electricity_bill
RENAME name TO full_name; 

Now, let’s verify the modifying user-defined type by using the following CQL query given below.

DESCRIBE TYPE Electricity_bill; 

Output:

Restriction: In the case of modifying UDTs, there is a restriction that modifying UDTs in the primary key is not supported and also not supported for the index column and changing column type of UDTs is also not supported.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :