Fixed-point types are variable-length, precise numeric types. DECIMAL is equivalent to NUMERIC. The syntax is as follows:
DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]
M represents the total number of digits (precision) that can be stored, and D represents the number of digits after the decimal point (scale). The decimal point and the negative sign "-" are not counted in M. If D is 0, the value has no decimal point or fractional part. The maximum number of valid digits in the integer part is equal to the value of M minus D, which is the precision minus the scale. All basic calculations involving DECIMAL columns (+, -, *, /) use 65 digits of precision.
The maximum value of M for DECIMAL is 65, and the maximum value of 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 Database automatically adds the UNSIGNED attribute to the column. If you specify UNSIGNED, negative values are not allowed.
For example, DECIMAL(5,2) has a maximum of 3 valid digits in the integer part and 2 valid digits in the fractional part, so the value range is [-999.99, 999.99]. If you also specify UNSIGNED, the value range is [0, 999.99].
The following types are synonyms for DECIMAL. FIXED is used for compatibility with other database systems.
DEC[(M[,D])] [UNSIGNED] [ZEROFILL], NUMERIC[(M[,D])] [UNSIGNED] [ZEROFILL], FIXED[(M[,D])] [UNSIGNED] [ZEROFILL]