# Data types

A column's data type defines which values it accepts and how they are converted, compared and returned. CoordinatorDB provides checked native numeric, temporal, collection and domain types alongside legacy SQL affinity declarations.

Type names ignore case: `UInt8` and `uint8` mean the same eight-bit unsigned type. Parameter values, field names, JSON paths and Enum labels follow their individual contracts.

## Choosing a type

| Data                                  | Types                                               |
| ------------------------------------- | --------------------------------------------------- |
| Whole numbers and counters            | `Int8` through `Int256`; `UInt8` through `UInt256`. |
| Exact decimal amounts                 | `Decimal(P, S)`, including `NUMERIC(P, S)`.         |
| Approximate measurements              | `Float32`, `Float64`, `BFloat16`.                   |
| Text and fixed-width bytes            | `String`, `VARCHAR(n)`, `FixedString(n)`.           |
| Flags and fixed vocabularies          | `Bool`, `Enum8`, `Enum16`.                          |
| Calendar dates and timestamps         | `Date`, `Date32`, `DateTime`, `DateTime64`.         |
| Date-independent clocks and durations | `Time`, `Time64`, `Interval`.                       |
| Repeated or structured values         | `Array`, `Tuple`, `Map`, `Nested`, `JSON`.          |
| Alternative or varying value types    | `Variant`, `Dynamic`.                               |
| Identifiers and addresses             | `UUID`, `IPv4`, `IPv6`, `inet`, `cidr`.             |
| Spatial values and numeric vectors    | Geometry aliases and `QBit`.                        |
| Partial aggregate results             | `AggregateFunction`, `SimpleAggregateFunction`.     |
| Full-text search values               | `tsvector`, `tsquery`.                              |

Use the [IP address functions](https://coordinatordb.com/docs/reference/functions/regular-functions/ip-address-functions) for `inet`/`cidr`, and [search functions](https://coordinatordb.com/docs/reference/functions/regular-functions/string-search-functions) for `tsvector`/`tsquery`.

## Declaring and converting values

Native declarations validate inserts, updates, defaults, generated values and explicit casts. The same range and shape rules apply wherever a value enters the declared type.

```sql
CREATE TABLE products
(
    id UInt32 PRIMARY KEY,
    name String NOT NULL,
    price Decimal(18, 2),
    tags Array(String)
);
INSERT INTO products VALUES (1, 'Notebook', '12.50', '["paper","office"]');
```

```sql
SELECT id, name, price, array_length(tags) AS tag_count
FROM products
FORMAT csv;
```

```text
1,"Notebook",12.50,2
```

Use `CAST(expression AS Type)` to convert explicitly, and `to_type_name` to inspect a native value's type. Individual type pages describe accepted inputs and conversion errors.

## NULL values

Top-level columns permit SQL `NULL` unless declared `NOT NULL`. Inside typed collections, use `Nullable(T)` for members that can be missing. A top-level `Array(UInt8)` column can therefore be `NULL`, but its non-`NULL` arrays cannot contain `NULL` elements.

## Legacy declarations

`INTEGER`, `REAL`, `TEXT` and `BLOB` follow SQLite-style affinity. `NUMERIC` is an exact Decimal declaration, defaulting to `Decimal(10, 0)`; use `LEGACY_NUMERIC` for SQLite numeric affinity.

`STRICT` tables enforce their allowed value classes; `ANY` preserves a supplied value's class. A ClickHouse table `ENGINE` clause is not required or supported.

## Type reference

* [AggregateFunction](https://coordinatordb.com/docs/reference/data-types/aggregatefunction)

* [Array](https://coordinatordb.com/docs/reference/data-types/array)

* [Bool](https://coordinatordb.com/docs/reference/data-types/bool)

* [Date](https://coordinatordb.com/docs/reference/data-types/date)

* [Date32](https://coordinatordb.com/docs/reference/data-types/date32)

* [DateTime](https://coordinatordb.com/docs/reference/data-types/datetime)

* [DateTime64](https://coordinatordb.com/docs/reference/data-types/datetime64)

* [Decimal](https://coordinatordb.com/docs/reference/data-types/decimal)

* [Dynamic](https://coordinatordb.com/docs/reference/data-types/dynamic)

* [Enum](https://coordinatordb.com/docs/reference/data-types/enum)

* [FixedString](https://coordinatordb.com/docs/reference/data-types/fixedstring)

* [Floating-point numbers](https://coordinatordb.com/docs/reference/data-types/float)

* [Geometry types](https://coordinatordb.com/docs/reference/data-types/geometry-types)

* [Integers](https://coordinatordb.com/docs/reference/data-types/int-uint)

* [IPv4](https://coordinatordb.com/docs/reference/data-types/ipv4)

* [IPv6](https://coordinatordb.com/docs/reference/data-types/ipv6)

* [LowCardinality](https://coordinatordb.com/docs/reference/data-types/lowcardinality)

* [Map](https://coordinatordb.com/docs/reference/data-types/map)

* [Nested](https://coordinatordb.com/docs/reference/data-types/nested-data-structures)

* [JSON](https://coordinatordb.com/docs/reference/data-types/json)

* [Nullable](https://coordinatordb.com/docs/reference/data-types/nullable)

* [QBit](https://coordinatordb.com/docs/reference/data-types/qbit)

* [SimpleAggregateFunction](https://coordinatordb.com/docs/reference/data-types/simpleaggregatefunction)

* [Interval](https://coordinatordb.com/docs/reference/data-types/special-data-types/interval)

* [String](https://coordinatordb.com/docs/reference/data-types/string)

* [Time](https://coordinatordb.com/docs/reference/data-types/time)

* [Time64](https://coordinatordb.com/docs/reference/data-types/time64)

* [Tuple](https://coordinatordb.com/docs/reference/data-types/tuple)

* [UUID](https://coordinatordb.com/docs/reference/data-types/uuid)

* [Variant](https://coordinatordb.com/docs/reference/data-types/variant)

* [Domain types](https://coordinatordb.com/docs/reference/data-types/domains)

* [Special data types](https://coordinatordb.com/docs/reference/data-types/special-data-types)
