Uuid Data Type in Cassandra - Cassandra / CQL Tutorial

Uuid Data Type in Cassandra

Uuid in Cassandra is used to store Standard Universally unique identifier values.We can use Uuid() function to generate them.

Let's create a sample table tbs with Id of data type Uuid and insert some records.

CQLSH:techbrotherstutorials>CREATE TABLE tbs 
             ( 
                          id UUID PRIMARY KEY, 
                          NAME VARCHAR 
             );

Insert couple of records in table by using CQL

CQLSH:techbrotherstutorials>INSERT INTO tbs 
            (  id,  NAME  ) 
            VALUES 
            (            Uuid(), 
                        'Doe John' 
            ); 

 

 CQLSH:techbrotherstutorials>INSERT INTO tbs 
            (  id,  NAME ) 
            VALUES 
            ( 
                        Uuid(), 
                        'Mike' 
            );

Check the data in table by using Select query in CQL

CQLSH:techbrotherstutorials>SELECT * 
FROM   tbs;