Updated on 2024-11-11 GMT+08:00

Data Types

The data types of GaussDB are the same as those of MySQL in most function scenarios, but there are some differences.

  • Unless otherwise specified, the precision, scale, and number of bits of some data types cannot be defined as floating-point values. You are advised to use valid integer values.
  • The command output of GaussDB ends with \0. MySQL displays the entire character string. Therefore, GaussDB truncates the bytes after \0, but MySQL does not.

    Example:

    -- GaussDB
    m_db=# SELECT FORMAT(1000, 4, 'bg_BG');
     format 
    --------
     1
    (1 row)
    m_db=# SELECT CONCAT('123', b'00000000', 'aa');
     concat 
    --------
     123
    (1 row)
    
    -- MySQL
    mysql> SELECT FORMAT(1000, 4, 'bg_BG');
    +--------------------------+
    | FORMAT(1000, 4, 'bg_BG') |
    +--------------------------+
    | 1 000,0000               |
    +--------------------------+
    1 row in set (0.01 sec)
    mysql> SELECT CONCAT('123', b'00000000', 'aa');
    +----------------------------------+
    | CONCAT('123', b'00000000', 'aa') |
    +----------------------------------+
    | 123 aa                           |
    +----------------------------------+
    1 row in set (0.00 sec)