Skip to main content

Supported types

CockroachDB supports the following data types.

Data type conversions and casts

CockroachDB supports explicit type conversions using the following methods:
  • <type 'string literal', to convert from the literal representation of a value to a value of that type. For example: DATE '2008-12-21', INT '123', or BOOL 'true'.
  • <value::<data type, or its equivalent longer form CAST(<value AS <data type>), which converts an arbitrary expression of one built-in type to another (this is also known as type coercion or “casting”). For example: NOW()::DECIMAL, VARIANCE(a+2)::INT.
To create constant values, consider using a instead of a cast, as it provides more predictable results.
  • Other when the type is not a SQL type, for example from_ip(), to_ip() to convert IP addresses between STRING and BYTES values.
CockroachDB also supports implicit casting from string literals to arrays of all data types except the following:
  • Box2D
  • GEOGRAPHY
  • GEOMETRY
For an example, see . You can find each data type’s supported conversion and casting on its respective page in its section Supported casting & conversion.

See also