Varchar Data Type in Cassandra
Varchar data type is same like Text Data type in Cassandra. Varchar data type in Cassandra is used to save UTF-8 encoded string values. I was trying to find what is the difference between Text and Varchar data type in Cassandra but look like they are same. I created the tbs table with column "Name" of varchar type. After creating the table when I checked the definition of table by using describe keyword in CQL, it shows the data type of "Name" column as text.
CQLSH:techbrotherstutorials>CREATE TABLE tbs
(
id INT PRIMARY KEY,
NAME Varchar
);
(
id INT PRIMARY KEY,
NAME Varchar
);
Let's check the definition of table by using Describe Table "TableName" in CQL.
CQLSH:techbrotherstutorials>describe TABLE tbs;
Let's insert couple of records in table which has Name column as varchar data type.
CQLSH:techbrotherstutorials>INSERT INTO tbs
(
id, NAME
)
VALUES
( 1, 'Doe John' );
(
id, NAME
)
VALUES
( 1, 'Doe John' );
CQLSH:techbrotherstutorials>INSERT INTO tbs
(
id, NAME
)
VALUES
( 2, 'Test_varchar_123' );
(
id, NAME
)
VALUES
( 2, 'Test_varchar_123' );
Check the data in table by using Select query in CQL
CQLSH:techbrotherstutorials>SELECT id,
NAME
FROM tbs;
NAME
FROM tbs;