In this post, we are going to introduce all data types that CockroachDB supported so that you can use them properly in CockroachDB.

All supported data types

Name Description Size
ARRAY A 1-dimensional, 1-indexed, homogenous array of any non-array data type. Variable, but recommended under 1 MB.
BOOL or BOOLEAN A Boolean value. 1 byte in width.
BYTES, BYTEA, or BLOB A string of binary characters. Variable, but recommended under 1 MB.
COLLATE It lets you sort STRING values according to language- and country-specific rules, known as collations.  
DATE A date value, a year, month, and day. 8 bytes in width.
DECIMAL, DEC, or NUMERIC An exact, fixed-point number. Variable, but recommended under 64 kilobytes.
FLOAT A 64-bit, inexact, floating-point number. 8 bytes in width.
INET An IPv4 or IPv6 address. 32 bits for IPv4 or 128 bits for IPv6.
INT A signed integer, up to 64 bits. Variable.
INTERVAL A span of time.  24 bytes in width.
JSONB, or JSON JSON (JavaScript Object Notation) data. Variable, but recommended under 1 MB.
SERIAL A unique 64-bit signed integer. Variable.
STRING A string of Unicode characters. Variable, but recommended under 64 kilobytes.
TIME or TIME WITHOUT TIME ZONE A time of day with no time zone. 8 bytes in width.
TIMESTAMP A date and time pairing. 12 bytes in width.
UUID A 128-bit hexadecimal value. 128 bits in width.

INT types

Name Allowed Width Aliases
INT 64-bit INTEGER, INT8, INT64, BIGINT
INT4 32-bit None
INT2 16-bit SMALLINT
BIT 1-bit None
BIT(n) n-bit None

Notes:

  • In PosgreSQL, JSONB and JSON are two different data types. In CockroachDB, the JSONB / JSON data type is similar to the JSONB data type in PostgreSQL.
  • The SERIAL type is equivalent to INT DEFAULT unique_rowid().
  • These are aliases for SERIAL:
    • SERIAL2
    • SERIAL4
    • SERIAL8
    • SMALLSERIAL
    • BIGSERIAL
  • SERIAL2 and SERIAL4 are the same as SERIAL and store 8-byte values, not 2- or 4-byte values as their names might suggest.
  • These are aliases for STRING:
    • CHARACTER
    • CHAR
    • VARCHAR
    • TEXT

Looking for a good GUI tool to work with CockroachDB database? Try TablePlus.

TablePlus is a modern, native client with intuitive GUI tools to create, access, query & edit multiple relational databases: MySQL, PostgreSQL, SQLite, Microsoft SQL Server, Amazon Redshift, MariaDB, CockroachDB, Vertica, Cassandra, Oracle, and Redis.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

On Linux? Download TablePlus for Linux

Need a quick edit on the go? Download TablePlus for iOS.

TablePlus in Dark mode