OceanBase Database supports all standard SQL numeric types, including exact numeric types (INTEGER, SMALLINT, DECIMAL, and NUMERIC), approximate numeric types (FLOAT and DOUBLE), the BIT data type for storing bit values, and extended types (TINYINT, MEDIUMINT, BIGINT, and SERIAL).
Note
- The
BOOL/BOOLEANkeyword is a synonym forTINYINT. - The
INTkeyword is a synonym forINTEGER.
Numeric type categories
The numeric types supported by the current version of OceanBase Database can be categorized as follows:
Integer types:
BOOL,BOOLEAN,TINYINT,SMALLINT,MEDIUMINT,INT,INTEGER,BIGINT, andSERIAL.Fixed-point types:
DECIMALandNUMERIC.Floating-point types:
FLOATandDOUBLE.Bit-value types:
BIT.
When defining numeric types, you can specify the precision (field length) and scale (number of decimal places). The meanings of precision and scale may vary for different numeric types. For more information, see the descriptions of each type.
ZEROFILL attribute
You can specify the minimum display width of a numeric type by using the ZEROFILL keyword. This also implicitly defines the type as UNSIGNED. If the actual display width of the data is less than the minimum display width, leading zeros are added to both the integer and decimal parts to fill the display width to the minimum display width.
For example:
INT(5) ZEROFILL: When the data value is123, it will be displayed as00123.DECIMAL(10, 5) ZEROFILL: When the data value is123.456, it will be displayed as00123.45600.
