Cassandra – CQL Datatypes

CQL provides a rich set of built-in data types, including collection types. Along with these data types, users can also create their own custom data types. The following table provides a list of built-in data types available in CQL.

Data TypeConstantsDescription
asciistringsRepresents ASCII character string
bigintbigintRepresents 64-bit signed long
blobblobsRepresents arbitrary bytes
BooleanbooleansRepresents true or false
counterintegersRepresents counter column
decimalintegers, floatsRepresents variable-precision decimal
doubleintegersRepresents 64-bit IEEE-754 floating point
floatintegers, floatsRepresents 32-bit IEEE-754 floating point
inetstringsRepresents an IP address, IPv4 or IPv6
intintegersRepresents 32-bit signed int
textstringsRepresents UTF8 encoded string
timestampintegers, stringsRepresents a timestamp
timeuuiduuidsRepresents type 1 UUID
uuiduuidsRepresents type 1 or type 4
UUID
varcharstringsRepresents uTF8 encoded string
varintintegersRepresents arbitrary-precision integer

Collection Types

Cassandra Query Language also provides a collection data types. The following table provides a list of Collections available in CQL.

CollectionDescription
listA list is a collection of one or more ordered elements.
mapA map is a collection of key-value pairs.
setA set is a collection of one or more elements.

User-defined datatypes

Cqlsh provides users a facility of creating their own data types. Given below are the commands used while dealing with user defined datatypes.

  • CREATE TYPE − Creates a user-defined datatype.
  • ALTER TYPE − Modifies a user-defined datatype.
  • DROP TYPE − Drops a user-defined datatype.
  • DESCRIBE TYPE − Describes a user-defined datatype.
  • DESCRIBE TYPES − Describes user-defined datatypes.

Leave a Reply