Smallint Data Type in Cassandra Query Language - Cassandra / CQL Tutorial

Smallint Data Type in Cassandra Query Language ( CQL)

Smallint Data type in Cassandra Query Language ( CQL) takes 2 Bytes to store the value. Smallint data type in Cassandra Query Language( CQL) can store data from -2^15 (-32,768) to 2^15-1 (32,767).
Let's create tables with Smallint data type in CQL by using below script. In below example Smallint data type is used for Salary column.
CQLSH:techbrotherstutorials>CREATE TABLE tbs 
             ( 
                          id     INT PRIMARY KEY, 
                          NAME   VARCHAR, 
                          salary SMALLINT 
             );

Insert some sample data in table by using CQL
CQLSH:techbrotherstutorials>INSERT INTO tbs 
            (id,  NAME, salary) 
VALUES      (1, 'Aamir',  4000); 

CQLSH:techbrotherstutorials>INSERT INTO tbs 
            (id, NAME, salary) 
VALUES      (2, 'Jon Does', -32000); 

Use Select query in CQL to get the data from table
CQLSH:techbrotherstutorials>SELECT * 
FROM   tbs; 

No comments:

Post a Comment