GlareDB

Data Types

Scalar Data Types

SQL AliasInternal TypeDescription
TINYINT, INT1Int8Signed 8-bit (1-byte) integer
SMALLINT, INT2Int16Signed 16-bit (2-byte) integer
INT, INTEGER, INT4Int32Signed 32-bit (4-byte) integer
BIGINT, INT8Int64Signed 64-bit (8-byte) integer
UTINYINT, UINT1UInt8Unsigned 8-bit (1-byte) integer
USMALLINT, UINT2UInt16Unsigned 16-bit (2-byte) integer
UINT, UINT4UInt32Unsigned 32-bit (4-byte) integer
UBIGINT, UINT8UInt64Unsigned 64-bit (8-byte) integer
HALF, FLOAT2Float16Half precision (2-byte) floating-point number
REAL, FLOAT, FLOAT4Float32Single precision (4-byte) floating-point number
DOUBLE, FLOAT8Float64Double precision (8-byte) floating-point number
DECIMAL(p,s), NUMERIC(p,s)Decimal64/Decimal128Fixed precision decimal
BOOL, BOOLEANBooleanBoolean (true/false)
DATEDate32/Date64Calendar date
TIMESTAMPTimestampA date with time
INTERVALIntervalA time interval
VARCHAR, TEXT, STRINGUtf8A variable length utf8 string
BLOB, BINARYBinaryA variable length binary blob

Decimals

Decimals are defined with a precision (width) and scale, and are used to represent fixed precision values. The precision indicates the total number of digits the value can hold, and scale indicates the number of digits to the right of decimal point.

When specifying DECIMAL in a SQL query, the default precision is 18 and default scale is 3. Precision and scale can be used with the syntax DECIMAL(p, s).

For example, casting column a to a decimal with a precision of 8 and scale of 2:

SELECT a::DECIMAL(8, 2);

Decimal literals in SQL queries are parsed into a decimal type with the exact precision and scale needed to hold the value.

A literal value of '5.43' will be parsed as a DECIMAL(3, 2). This can be verified with a DESCRIBE statement:

DESCRIBE SELECT 5.43