DECIMAL data type
Decimal is a numeric data type used with scale
constraint.
Syntax
DECIMAL[({SCALE value})]
Arguments
Argument | Description |
---|---|
DECIMAL | Numeric data type ideally used for decimal numbers where the exact scale is known. |
SCALE | Constraint that determines the number of digits of precision to store after the decimal point. integer value of zero or more. Defaults to two (2) |
Additional information
- Values added to a column with DECIMAL data type are truncated to the stated number of decimal places.
- Users should round their values prior to ingestion.
- STRING values added to Columns with DECIMAL data type are parsed as floats where possible
- Aggregate and range queries work best with DECIMAL data types.
- Use STRING data type if you intend to run queries to group by or search for distinct values.
Examples
CREATE TABLE with all data types
create table allcoltypes
(
_id id,
intcol int min 0 max 10000,
boolcol bool,
timestampcol timestamp timeunit 'ms',
decimalcol decimal(2),
stringcol string,
stringsetcol stringset,
stringsetcolq stringsetq timequantum 'YMD' ttl '24h',
idcol id,
idsetcol idset,
idsetcolq idsetq timequantum 'YMD' ttl '24h',
vectorcol vector(768)
)
with comment 'table containing all column types';
CREATE TABLE with decimal data type
create table products
(_id id, item string, price decimal(2) stock int);
create table services
(_id id, servicelist string, price decimal(2));