Skip to main content

Numeric Types

The following table lists the numeric types supported by Relyt.

NameStorage sizeValue rangeDescription
bigint8 bytes-9223372036854775808 to 9223372036854775807Stores large-range integers.
integer4 bytes-2147483648 to +2147483647Stores integers. This type is the common choice for storing integers, because it offers the best balance between range, size, and performance.
smallint2 bytes-32768 to +32767Stores small-range integers.
double precision8 bytes15 decimal digits precisionStores numbers with a fractional part.
real4 bytes6 decimal digits precisionStores single-precision floating-point numbers.
decimalVariable128-bit signed integers with up to 38 digits of precisionStores exact numbers with user-specified precision.
note

Relyt does not support storage of decimals. decimal can only be used in computation.

Integer types​

The smallint, integer, and bigint types store integers of different ranges. Storing value outside of the permitted range will result in an error.

Floating-point types​

The real and double precision types are inexact, variable-precision numeric types.

They are inexact, so slight discrepancies appear from time to time when you store and retrieve values. If you require exact storage or computation, do not use these types.

Decimal type​

The decimal type is used to store numbers of which the precision is user-defined. To define a decimal column, you need to specify the precision and the scale:

decimal(precision, scale)

precision specifies the number of digits on the both sides of the decimal point. The maximum value is 38. If not specified, the default precision 18 is used.

scale specifies the number of digits on the right of the decimal point. The maximum value is 37. If not specified, the default scale 0 is used.

For example, number 3.1415926 has a precision of 8 and a scale of 7.

If the scale of an input value is greater than the scale of the column to which the value is loaded, the value is rounded to the specified scale. However, results of explicit casts of values selected from tables will not be rounded.

info

As you can see from the previous information, the precision for a decimal column is the sum of the number of digits on the left side of the decimal point and the scale, therefore:

If the number of digits you specify on the left of the decimal point in an input value surpasses the precision of the column minus the scale, the value cannot be copied to the column. The scale that you specify for a decimal column cannot be larger than the precision of the column.