Skip to content
Discord Get Started

Data Types

db9 supports 23 data types. All data is stored in UTF-8 encoding.

SQL TypeAliasesDescription
BOOLEANBOOLTrue/false values
INTEGERINT, INT44-byte signed integer
BIGINTINT88-byte signed integer
DOUBLE PRECISIONFLOAT88-byte IEEE 754 floating point
NUMERICNUMERIC(p,s), DECIMALArbitrary-precision number (up to 28-29 significant digits)
TEXTVariable-length UTF-8 string
VARCHAR(n)CHARACTER VARYING(n)Length-limited text (max n characters)
BYTEARaw byte array
TIMESTAMPTIMESTAMP WITHOUT TIME ZONETimestamp (millisecond precision)
TIMESTAMPTZTIMESTAMP WITH TIME ZONETimestamp with timezone (millisecond precision)
DATECalendar date (days)
TIMETIME WITHOUT TIME ZONETime of day (microsecond precision)
INTERVALTime interval (months + milliseconds)
UUID128-bit UUID
JSONJSON data (original text preserved)
JSONBJSON data in canonical binary form
SERIALAuto-incrementing 4-byte integer
BIGSERIALAuto-incrementing 8-byte integer
type[]Array of any supported type
vector(N)Dense float vector of N dimensions (pgvector-compatible)
TSVECTORFull-text search document representation
TSQUERYFull-text search query
NAME63-byte identifier (PostgreSQL system type)

Not supported: SMALLINT / INT2, REAL / FLOAT4, CHAR(n) (fixed-length). Use INTEGER, DOUBLE PRECISION, and VARCHAR(n) instead.

Timestamp precision: Timestamps are stored at millisecond precision, not microsecond as in standard PostgreSQL. Precision parameters 0–6 are accepted in syntax, but sub-millisecond precision cannot be represented.

Intervals store months and sub-month components separately, enabling calendar-aware arithmetic (e.g., adding 1 month to January 31 gives February 28/29). The sub-month component is stored in milliseconds.

The type system uses two coercion strategies matching PostgreSQL behavior:

UNION / CASE / COALESCE / VALUES (“Text wins”)

Section titled “UNION / CASE / COALESCE / VALUES (“Text wins”)”

When mixing Text with a typed value, the result is Text. Example: SELECT 1 UNION SELECT 'a' resolves to TEXT.

When comparing Text with a typed value, the text literal is coerced to the typed side. Example: WHERE col = '42' coerces '42' to the column’s type.

Int32Int64Float64Numeric. When two numeric types are mixed, the higher-precedence type wins.

  • Date + Timestamp = Timestamp
  • Timestamp + TimestampTz = TimestampTz
  • Date + TimestampTz = TimestampTz
ContextWhen UsedBehavior
ExplicitCAST(x AS type) or x::typeMost permissive. Allows rounding (Float to Int), Bool↔Int, VARCHAR truncation
AssignmentINSERT/UPDATE column coercionMedium. Rejects fractional Float→Int, rejects Bool↔Int, errors on VARCHAR overflow
ImplicitComparison coercionStrictest. Similar to Assignment
CastExplicitAssignment
2.7::INTEGERRounds to 3Rejects (fraction)
TRUE::INTEGERReturns 1Rejects
42::BOOLEANReturns trueRejects
'hello'::VARCHAR(3)Truncates to “hel”Errors if > 3 chars
NULL to any typeAlways succeedsAlways succeeds