> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cockroachlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Types

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

## Supported types

CockroachDB supports the following data types.

| Type | Description | Example |
| - | - | - |
| <InternalLink path="array">`ARRAY`</InternalLink> | A 1-dimensional, 1-indexed, homogeneous array of any non-array data type. | `{"sky","road","car"}` |
| <InternalLink path="bit">`BIT`</InternalLink> | A string of binary digits (bits). | `B'10010101'` |
| <InternalLink path="bool">`BOOL`</InternalLink> | A Boolean value. | `true` |
| <InternalLink path="bytes">`BYTES`</InternalLink> | A string of binary characters. | `b'\141\061\142\062\143\063'` |
| <InternalLink path="collate">`COLLATE`</InternalLink> | The `COLLATE` feature lets you sort <InternalLink path="string">`STRING`</InternalLink> values according to language- and country-specific rules, known as collations. | `'a1b2c3' COLLATE en` |
| <InternalLink path="citext">`CITEXT`</InternalLink> | Case-insensitive text. | `'Roach'` |
| <InternalLink path="date">`DATE`</InternalLink> | A date. | `DATE '2016-01-25'` |
| <InternalLink path="decimal">`DECIMAL`</InternalLink> | An exact, fixed-point number. | `1.2345` |
| <InternalLink path="domain">`DOMAIN`</InternalLink> | A user-defined data type based on an existing data type, with optional constraints that restrict its allowed values. | `CREATE DOMAIN postal_code AS STRING CHECK (VALUE ~ '^[0-9]{5}$')` |
| <InternalLink path="enum">`ENUM`</InternalLink> | A user-defined data type comprised of a set of static values. | `ENUM ('club, 'diamond', 'heart', 'spade')` |
| <InternalLink path="float">`FLOAT`</InternalLink> | A 64-bit, inexact, floating-point number. | `1.2345` |
| <InternalLink path="inet">`INET`</InternalLink> | An IPv4 or IPv6 address. | `192.168.0.1` |
| <InternalLink path="int">`INT`</InternalLink> | A signed integer, up to 64 bits. | `12345` |
| <InternalLink path="interval">`INTERVAL`</InternalLink> | A span of time. | `INTERVAL '2h30m30s'` |
| <InternalLink path="jsonb">`JSONB`</InternalLink> | JSON (JavaScript Object Notation) data. | `'{"first_name": "Lola", "last_name": "Dog", "location": "NYC", "online" : true, "friends" : 547}'` |
| <InternalLink path="ltree">`LTREE`</InternalLink> | A label path representing a hierarchical tree-like structure. | `'Top.Countries.Europe.France'` |
| <InternalLink path="null-handling">`NULL`</InternalLink> | The undefined value. | `NULL` |
| <InternalLink path="oid">`OID`</InternalLink> | An unsigned 32-bit integer. | `4294967295` |
| <InternalLink path="serial">`SERIAL`</InternalLink> | A pseudo-type that combines an <InternalLink path="int">integer type</InternalLink> with a <InternalLink path="default-value">`DEFAULT` expression</InternalLink>. | `148591304110702593` |
| <InternalLink path="string">`STRING`</InternalLink> | A string of Unicode characters. | `'a1b2c3'` |
| <InternalLink path="time">`TIME`<br />`TIMETZ`</InternalLink> | `TIME` stores a time of day in UTC.<br /> `TIMETZ` converts `TIME` values with a specified time zone offset from UTC. | `TIME '01:23:45.123456'`<br /> `TIMETZ '01:23:45.123456-5:00'` |
| <InternalLink path="timestamp">`TIMESTAMP`<br />`TIMESTAMPTZ`</InternalLink> | `TIMESTAMP` stores a date and time pairing in UTC.<br />`TIMESTAMPTZ` converts `TIMESTAMP` values with a specified time zone offset from UTC. | `TIMESTAMP '2016-01-25 10:10:10'`<br />`TIMESTAMPTZ '2016-01-25 10:10:10-05:00'` |
| <InternalLink path="tsquery">`TSQUERY`</InternalLink> | A list of lexemes and operators used in <InternalLink path="full-text-search">full-text search</InternalLink>. | `'list' & 'lexem' & 'oper' & 'use' & 'full' & 'text' & 'search'` |
| <InternalLink path="tsvector">`TSVECTOR`</InternalLink> | A list of lexemes with optional integer positions and weights used in <InternalLink path="full-text-search">full-text search</InternalLink>. | `'full':13 'integ':7 'lexem':4 'list':2 'option':6 'posit':8 'search':15 'text':14 'use':11 'weight':10` |
| <InternalLink path="uuid">`UUID`</InternalLink> | A 128-bit hexadecimal value. | `7f9c24e8-3b12-4fef-91e0-56a2d5a246ec` |
| <InternalLink path="vector">`VECTOR`</InternalLink> | A fixed-length array of floating-point numbers. | `[1.0, 0.0, 0.0]` |

## 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`.

<Tip>
  To create constant values, consider using a
  type annotation
  instead of a cast, as it provides more predictable results.
</Tip>

* Other <InternalLink path="functions-and-operators">built-in conversion functions</InternalLink> 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:

* <InternalLink path="bytes">`BYTES`</InternalLink>
* <InternalLink path="enum">`ENUM`</InternalLink>
* <InternalLink path="jsonb">`JSONB`</InternalLink>
* <InternalLink path="serial">`SERIAL`</InternalLink>
* `Box2D` <InternalLink path="architecture/glossary#data-types">(spatial type)</InternalLink>
* `GEOGRAPHY` <InternalLink path="architecture/glossary#data-types">(spatial type)</InternalLink>
* `GEOMETRY` <InternalLink path="architecture/glossary#data-types">(spatial type)</InternalLink>

For an example, see <InternalLink path="array#implicit-casting">Implicit casting to `ARRAY`s</InternalLink>.

You can find each data type's supported conversion and casting on its
respective page in its section **Supported casting & conversion**.

## See also

* <InternalLink path="create-type">`CREATE TYPE`</InternalLink>
* <InternalLink path="alter-type">`ALTER TYPE`</InternalLink>
* <InternalLink path="drop-type">`DROP TYPE`</InternalLink>
* <InternalLink path="show-types">`SHOW TYPES`</InternalLink>
