Primitive types
Primitive types store basic values such as numbers, text, booleans, and dates.
Table of Content
Null Values
Definition:
NULL represents a missing or unknown value.
Notes:
Not the same as
0,''(empty string),{}(empty object),[](empty array), or any zero-equivalent.Columns omitted during
INSERTgetNULLvalues.Outer joins produce
NULLfor unmatched rows.Use
NOT NULLto preventNULLvalues.
Examples:
Preventing NULL values:
Boolean
Definition:
Stores a logical value: TRUE or FALSE.
Example:
VARCHAR(n)
Definition:
Variable-length strings, maximum n characters (1 ≤ n ≤ 2^31 - 1).
Behavior:
Exceeding
ncauses an error (unless cast).Trailing spaces are truncated.
Casting truncates without error.
Example:
CHARACTER(n)
Definition:
Fixed-length strings, blank-padded to n characters.
Behavior:
Over-length values cause an error (unless cast).
Shorter values are right-padded with spaces.
Casting truncates without error.
Example:
TEXT
Definition: Unbounded variable-length Unicode text.
Notes:
Max indexed length: 32,766 bytes (UTF-8) for column store.
Use
OBJECTfor structured JSON-like data.
Example:
json
Definition: PostgreSQL-compatible JSON type (only for casting, not table columns).
Examples:
Numeric types
CrateDB supports:
SMALLINTINTEGERBIGINTNUMERIC(precision, scale)REALDOUBLE PRECISION
Notes:
REALandDOUBLE PRECISIONare inexact (floating-point).Aggregates (
SUM,AVG) on floats may vary slightly due to rounding.Supports IEEE 754 special values:
NaN,Infinity,-Infinity,-0.
Example:
Inserting special values:
Last updated

