Updated on 2025-06-30 GMT+08:00

Numeric Data Types

Unless otherwise specified, the data type precision, scale, and number of bits in M-compatible mode of MySQL compatibility cannot be defined as floating-point values by default. You are advised to use valid integer values.

Table 1 Integer types

MySQL

GaussDB

Difference

BOOL

Supported, with differences

Output format: The output of SELECT TRUE/FALSE in GaussDB is t or f, and that in MySQL is 1 or 0.

MySQL: The BOOL/BOOLEAN type is actually mapped to the TINYINT type.

BOOLEAN

Supported, with differences

TINYINT[(M)] [UNSIGNED] [ZEROFILL]

Supported, with differences

Input format:
  • MySQL:

    If a character string with multiple decimal points (such as "1.2.3.4.5") is entered, MySQL will misparse the character string in loose mode, throw a warning, and insert the character string into the table successfully. For example, after "1.2.3.4.5" is inserted into the table, the value is 12.

  • GaussDB:

    If a character string with multiple decimal points (such as "1.2.3.4.5") is entered in loose mode, the characters after the second decimal point are truncated as invalid characters, a warning is thrown, and the character string is inserted into the table successfully. For example, after "1.2.3.4.5" is inserted into the table, the value is 1. After "1.6.3.4.5" is inserted into the table, the value is 2.

SMALLINT[(M)] [UNSIGNED] [ZEROFILL]

Supported, with differences

MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]

Supported, with differences

MySQL requires 3 bytes to store MEDIUMINT data.
  • The signed range is –8388608 to +8388607.
  • The unsigned range is 0 to +16777215.
GaussDB is mapped to the INT type. Four bytes are required for storage. The value range is determined based on boundary values.
  • The signed range is –8388608 to +8388607.
  • The unsigned range is 0 to +16777215.

For other differences, see the description below the table.

INT[(M)] [UNSIGNED] [ZEROFILL]

Supported, with differences

Input format:
  • MySQL:

    If a character string with multiple decimal points (such as "1.2.3.4.5") is entered, MySQL will misparse the character string in loose mode, throw a warning, and insert the character string into the table successfully. For example, after "1.2.3.4.5" is inserted into the table, the value is 12.

  • GaussDB:

    If a character string with multiple decimal points (such as "1.2.3.4.5") is entered in loose mode, the characters after the second decimal point are truncated as invalid characters, a warning is thrown, and the character string is inserted into the table successfully. For example, after "1.2.3.4.5" is inserted into the table, the value is 1. After "1.6.3.4.5" is inserted into the table, the value is 2.

INTEGER[(M)] [UNSIGNED] [ZEROFILL]

Supported, with differences

BIGINT[(M)] [UNSIGNED] [ZEROFILL]

Supported, with differences

Table 2 Arbitrary precision types

MySQL

GaussDB

Difference

DECIMAL[(M[,D])] [ZEROFILL]

Supported, with differences

MySQL DECIMAL uses a 9 x 9 array to store values. The integer part and decimal part are stored separately. If the length exceeds the value, the decimal part is truncated first. GaussDB truncates an integer that contains more than 81 digits.

NUMERIC[(M[,D])] [ZEROFILL]

Supported, with differences

DEC[(M[,D])] [ZEROFILL]

Supported, with differences

FIXED[(M[,D])] [ZEROFILL]

Supported, with differences

Table 3 Floating-point types

MySQL

GaussDB

Difference

FLOAT[(M,D)] [ZEROFILL]

Supported, with differences

The FLOAT data type does not support partitioned tables with the key partitioning policy.

FLOAT(p) [ZEROFILL]

Supported, with differences

The FLOAT data type does not support partitioned tables with the key partitioning policy.

DOUBLE[(M,D)] [ZEROFILL]

Supported, with differences

The DOUBLE data type does not support partitioned tables with the key partitioning policy.

DOUBLE PRECISION[(M,D)] [ZEROFILL]

Supported, with differences

The DOUBLE PRECISION data type does not support partitioned tables with the key partitioning policy.

REAL[(M,D)] [ZEROFILL]

Supported, with differences

The REAL data type does not support partitioned tables with the key partitioning policy.