Skip to main content
CockroachDB supports a wide range of data types for storing and manipulating different kinds of data. All PostgreSQL data types are supported with some extensions for distributed systems.

Supported Types

The following table lists all data types available in CockroachDB:
ARRAY
array
A 1-dimensional, 1-indexed, homogeneous array of any non-array data type.
SELECT ARRAY['sky','road','car'];
-- Result: {"sky","road","car"}
BIT
bit string
A string of binary digits (bits).
SELECT B'10010101';
BOOL
boolean
A Boolean value: true or false.
SELECT true, false;
BYTES
byte array
A string of binary characters.
SELECT b'\141\061\142\062\143\063';
DATE
date
A date without time zone information.
SELECT DATE '2016-01-25';
DECIMAL
numeric
An exact, fixed-point number. Use for monetary values and when precision is critical.
SELECT 1.2345::DECIMAL;
SELECT DECIMAL '99.99';
ENUM
enumerated
A user-defined data type comprised of a set of static values.
CREATE TYPE suit AS ENUM ('club', 'diamond', 'heart', 'spade');
FLOAT
floating-point
A 64-bit, inexact, floating-point number.
SELECT 1.2345::FLOAT;
SELECT FLOAT '123.45e-3';
INET
network address
An IPv4 or IPv6 address.
SELECT INET '192.168.0.1';
SELECT INET '2001:4f8:3:ba:2e0:81ff:fe22:d1f1';
INT
integer
A signed integer, up to 64 bits. Aliases: INTEGER, INT8, INT64, BIGINT.
SELECT 12345::INT;
SELECT -9223372036854775807::INT8;
INT2
smallint
A 16-bit signed integer. Alias: SMALLINT. Range: -32768 to +32767.
SELECT 100::INT2;
INT4
integer
A 32-bit signed integer. Range: -2147483648 to +2147483647.
SELECT 50000::INT4;
INTERVAL
duration
A span of time.
SELECT INTERVAL '2h30m30s';
SELECT INTERVAL '1 day 2 hours';
JSONB
json
JSON (JavaScript Object Notation) data stored in a binary format.
SELECT '{"name": "Lola", "age": 5}'::JSONB;
STRING
text
A string of Unicode characters. Aliases: TEXT, VARCHAR, CHAR.
SELECT 'hello world'::STRING;
SELECT STRING 'CockroachDB';
TIME
time
A time of day in UTC without date information.
SELECT TIME '01:23:45.123456';
TIMETZ
time with timezone
A time of day with a specified time zone offset from UTC.
SELECT TIMETZ '01:23:45.123456-5:00';
TIMESTAMP
timestamp
A date and time pairing in UTC.
SELECT TIMESTAMP '2016-01-25 10:10:10';
TIMESTAMPTZ
timestamp with timezone
A timestamp with a specified time zone offset from UTC.
SELECT TIMESTAMPTZ '2016-01-25 10:10:10-05:00';
UUID
uuid
A 128-bit hexadecimal universally unique identifier.
SELECT '7f9c24e8-3b12-4fef-91e0-56a2d5a246ec'::UUID;
SELECT gen_random_uuid();
VECTOR
vector
A fixed-length array of floating-point numbers for vector embeddings.
SELECT '[1.0, 0.0, 0.0]'::VECTOR(3);

Type Conversions and Casts

You can convert values between different data types using explicit casts:
Convert from a string literal to a specific type:
SELECT DATE '2008-12-21';
SELECT INT '123';
SELECT BOOL 'true';
For constant values, use type literals (e.g., DATE '2016-01-01') instead of casts for more predictable results.

Integer Size Considerations

By default, INT is an alias for INT8, which creates 64-bit signed integers. This differs from PostgreSQL’s default 32-bit INT.

JavaScript Compatibility

JavaScript represents numbers as 64-bit floats with only 53 bits of numeric accuracy. The maximum safe integer in JavaScript (2^53) is much smaller than CockroachDB’s INT maximum:
9223372036854775807  # CockroachDB INT8 max
   9007199254740991  # JavaScript safe integer max
If your application uses JavaScript, consider using INT4 (32-bit) or STRING for large integer values.

Changing Default Integer Size

You can change the default integer size using:
Session Variable
SET default_int_size = 4;  -- Use 32-bit integers
Cluster Setting
SET CLUSTER SETTING sql.defaults.default_int_size = 4;

Implicit Casting to Arrays

CockroachDB supports implicit casting from string literals to arrays of all data types except:
  • BYTES
  • ENUM
  • JSONB
  • SERIAL
  • Spatial types (BOX2D, GEOGRAPHY, GEOMETRY)
SELECT '{1,2,3}'::INT[];
-- Result: {1,2,3}

String Length Limits

To limit the length of a string column, use STRING(n) where n is the maximum number of characters:
CREATE TABLE users (
  username STRING(50),
  bio TEXT
);
Set length limits on indexed string columns to avoid performance issues. Very large string values in indexes can cause significant performance degradation.

Collations

STRING values support collations for language-specific sorting:
CREATE TABLE products (
  name STRING COLLATE en PRIMARY KEY
);

SELECT * FROM products ORDER BY name;

See Also

Build docs developers (and LLMs) love