Skip to main content

Data Types

General-Purpose Data Types

The table below shows all the built-in general-purpose data types. The alternatives listed in the aliases column can be used to refer to these types as well, however, note that the aliases are not part of the SQL standard and hence might not be accepted by other database engines.

NameAliasesDescription
BIGINTINT8, LONGsigned eight-byte integer
BITBITSTRINGstring of 1's and 0's
BOOLEANBOOL, LOGICALlogical boolean (true/false)
BLOBBYTEA, BINARY, VARBINARYvariable-length binary data
DATEcalendar date (year, month day)
DOUBLEFLOAT8, NUMERIC, DECIMALdouble precision floating-point number (8 bytes)
DECIMAL(prec, scale)fixed-precision number with the given width (precision) and scale
HUGEINTsigned sixteen-byte integer
INTEGERINT4, INT, SIGNEDsigned four-byte integer
INTERVALdate / time delta
REALFLOAT4, FLOATsingle precision floating-point number (4 bytes)
SMALLINTINT2, SHORTsigned two-byte integer
TIMEtime of day (no time zone)
TIMESTAMPDATETIMEcombination of time and date
TIMESTAMP WITH TIME ZONETIMESTAMPTZcombination of time and date that uses the current time zone
TINYINTINT1signed one-byte integer
UBIGINTunsigned eight-byte integer
UINTEGERunsigned four-byte integer
USMALLINTunsigned two-byte integer
UTINYINTunsigned one-byte integer
UUIDUUID data type
VARCHARCHAR, BPCHAR, TEXT, STRINGvariable-length character string

Nested / Composite Types

DuckDB supports four nested data types: LIST, STRUCT, MAP and UNION. Each supports different use cases and has a different structure.

NameDescriptionRules when used in a columnBuild from valuesDefine in DDL/CREATE
LISTAn ordered sequence of data values of the same type.Each row must have the same data type within each LIST, but can have any number of elements.[1, 2, 3]INT[ ]
STRUCTA dictionary of multiple named values, where each key is a string, but the value can be a different type for each key.Each row must have the same keys.{'i': 42, 'j': 'a'}STRUCT(i INT, j VARCHAR)
MAPA dictionary of multiple named values, each key having the same type and each value having the same type. Keys and values can be any type and can be different types from one another.Rows may have different keys.map([1,2],['a','b'])MAP(INT, VARCHAR)
UNIONA union of multiple alternative data types, storing one of them in each value at a time. A union also contains a discriminator "tag" value to inspect and access the currently set member type.Rows may be set to different member types of the union.union_value(num := 2)UNION(num INT, text VARCHAR)

Nesting

LISTs, STRUCTs, MAPs and UNIONs can be arbitrarily nested to any depth, so long as the type rules are observed.

-- Struct with lists
SELECT {'birds': ['duck', 'goose', 'heron'], 'aliens': NULL, 'amphibians': ['frog', 'toad']};
-- Struct with list of maps
SELECT {'test': [map([1, 5], [42.1, 45]), map([1, 5], [42.1, 45])]};
-- A list of unions
SELECT [union_value(num := 2), union_value(str := 'ABC')::UNION(str VARCHAR, num INTEGER)];