Notice
When using the DECIMAL type as the partitioning key and connecting to OceanBase AI Database via ODP, ensure that ODP is version V4.2.3 or later to guarantee accurate routing.
Fixed-point types are variable-length, exact numeric types. Their value range and precision depend on the precision and scale, as well as whether they are unsigned.
DECIMAL is equivalent to NUMERIC. The syntax is as follows:
DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]
M is the total number of digits that can be stored (Precision), and D is the number of digits after the decimal point (Scale). The decimal point and the negative sign "-" are not included in M. If D is 0, the value has no decimal point or fractional part. The maximum number of significant digits for the integer part is equal to M minus D, that is, Precision minus Scale. All basic operations (+, -, *, /) on columns with the DECIMAL data type use a precision of 65 bits.
The maximum value for M in DECIMAL is 65, and the maximum value for D is 30. If D is omitted, it defaults to 0. If M is omitted, it defaults to 10.
If you specify ZEROFILL for a numeric column, OceanBase AI Database automatically adds the UNSIGNED attribute to that column. If UNSIGNED is specified, negative values are not allowed.
For example, for the data type DECIMAL(5,2), the maximum number of significant digits for the integer part and the decimal part is 3 and 2 respectively. Therefore, the value range is [-999.99, 999.99]. If it is also defined as UNSIGNED, the value range is [0, 999.99].
The following types are also synonyms for DECIMAL. Among them, FIXED can be used for compatibility with other database systems.
DEC[(M[,D])] [UNSIGNED] [ZEROFILL], NUMERIC[(M[,D])] [UNSIGNED] [ZEROFILL], FIXED[(M[,D])] [UNSIGNED] [ZEROFILL]