Numeric types

Updated at:

PolarDB-X 1.0 supports the same numeric data types as MySQL, grouped into two categories by precision: exact and approximate.

Exact numeric data types

Integer types

PolarDB-X 1.0 supports the following integer types, which are fully compatible with MySQL in terms of storage size and value range:

Type Storage (bytes) Signed range Unsigned range
TINYINT 1 -128 to 127 0 to 255
SMALLINT 2 -32,768 to 32,767 0 to 65,535
MEDIUMINT 3 -8,388,608 to 8,388,607 0 to 16,777,215
INTEGER 4 -2,147,483,648 to 2,147,483,647 0 to 4,294,967,295
BIGINT 8 -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 0 to 18,446,744,073,709,551,615

All integer types support the UNSIGNED and ZEROFILL modifiers. UNSIGNED shifts the range to non-negative values. ZEROFILL left-pads displayed values with zeros to the declared display width.

Fixed-point types

Type Notes
DECIMAL Exact fixed-point number. Use DECIMAL(precision, scale) to specify the total number of significant digits (precision) and the number of digits after the decimal point (scale).
NUMERIC Equivalent to DECIMAL.

Use DECIMAL or NUMERIC when exact precision is required, such as for monetary amounts or scientific measurements.

Approximate numeric data types

Approximate types use floating-point representation, which can introduce rounding errors.

Warning

For values that require exact precision — such as monetary amounts — use DECIMAL instead of FLOAT, REAL, or DOUBLE PRECISION.

Type Notes
FLOAT Single-precision floating-point number (4 bytes).
REAL Double-precision floating-point number (8 bytes).
DOUBLE PRECISION Double-precision floating-point number; equivalent to REAL.

MySQL compatibility

All numeric data types in PolarDB-X 1.0 are fully compatible with MySQL. For complete specifications — including type modifiers and behavior details — see Numeric data types in the MySQL 5.7 Reference Manual.