User Defined Type in Cassandra
A user-defined type helps handling multiple fields of related information in a table. Multiple tables can be simplified to use fewer tables by using a user-defined type to represent the related fields of information. Here we will show you how to create and use user-defined types:
Use
CREATE TYPE
command to create a user defined type:CREATE TYPE user_basic_info ( birthday timestamp, nationality text, city text ); |
Now create table with this user defined type:
Insert data to users table:
INSERT INTO users (id, name, basics) VALUES ( '123' , 'Abhay' , { birthday : '1997-02-01' , nationality : 'Indian' , city : 'Delhi' }); |
0 comments:
Post a Comment