3
votes

What is the difference between Varchar and text data type in Cassandra CQL.

https://docs.datastax.com/en/cql/3.0/cql/cql_reference/cql_data_types_c.html

When I try to create a table with field data type as varchar it is creating as text data type

CREATE TABLE test ( empID int, first_name varchar, last_name varchar, PRIMARY KEY (empID) );

DESC test table gives me the below result.

CREATE TABLE test (
    empid int PRIMARY KEY,
    first_name text,
    last_name text
) WITH bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';

[cqlsh 5.0.1 | Cassandra 3.0.7.1158 | DSE 5.0.0 | CQL spec 3.4.0 | Native protocol v4]

1

1 Answers

3
votes

CQL data types doc, both text and varchar are UTF-8 strings. So both are one and the same.