Numeric Data Types
Integer
Unless otherwise specified, the precision, scale, and number of bits cannot be defined as the floating-point values in MYSQL-compatible mode by default. You are advised to use a valid integer type.
Differences in terms of the integer types:
- Input format:
- MySQL
For characters such as "asbd", "12dd", and "12 12", the system truncates them or returns 0 and reports a WARNING. Data fails to be inserted into a table in strict mode.
- GaussDB
- For integer types (TINYINT, SMALLINT, MEDIUMINT, INT, INTEGER, and BIGINT), if the invalid part of a character string is truncated, for example, "12@3", no message is displayed. Data is successfully inserted into a table.
- If the whole integer is truncated (for example, "@123") or the character string is empty, 0 is returned and data is successfully inserted into a table.
- MySQL
- Operators:
- +, -, and *
GaussDB: When INT, INTEGER, SMALLINT, or BIGINT is used for calculation, a value of the original type is returned and is not changed to a larger type. If the return value exceeds the range, an error is reported.
MySQL: The value can be changed to BIGINT for calculation.
- |, &, ^, and ~
GaussDB: The value is calculated in the bits occupied by the type. In GaussDB, ^ indicates the exponentiation operation. If the XOR operator is required, replace it with #.
MYSQL: The value is changed to a larger type for calculation.
- +, -, and *
- Type conversion of negative numbers:
GaussDB: The result is 0 in loose mode and an error is reported in strict mode.
MySQL: The most significant bit is replaced with a numeric bit based on the corresponding binary value, for example, (-1)::uint4 = 4294967295.
- Other differences:
The precision of INT[(M)] controls formatted output in MySQL. GaussDB supports only the syntax but does not support the function.
- Aggregate function:
- variance: indicates the sample variance in GaussDB and the population variance in MySQL.
- stddev: indicates the sample standard deviation in GaussDB and the overall standard deviation in MySQL.
- Display width:
- If ZEROFILL is not specified when the width information is specified for an integer column, the width information is not displayed in the table structure description.
- When the INSERT statement is used to insert a column of the character type, GaussDB pads 0s before inserting the column.
- The JOIN USING statement involves type derivation. In MySQL, the first table column is used by default. In GaussDB, if the result is of the signed type, the width information is invalid. Otherwise, the width of the first table column is used.
- For GREATEST/LEAST, IFNULL/IF, and CASE WHEN/DECODE, MySQL does not pad 0s. In GaussDB, 0s are padded when the type and width information is consistent.
- MySQL supports this function when it is used as the input or output parameter or return value of a function or stored procedure. GaussDB neither reports syntax errors nor supports this function.
For details about the differences between integer types in GaussDB and MySQL, see Table 1.
MySQL |
GaussDB |
Difference |
---|---|---|
BOOL |
Supported, with differences |
MySQL: The BOOL/BOOLEAN type is actually mapped to the TINYINT type. GaussDB: BOOL is supported.
TRUE and FALSE are standard expressions, compatible with SQL statements. |
BOOLEAN |
Supported, with differences |
|
TINYINT[(M)] [UNSIGNED] |
Supported, with differences |
For details, see Differences in terms of the integer types. |
SMALLINT[(M)] [UNSIGNED] |
Supported, with differences |
For details, see Differences in terms of the integer types. |
MEDIUMINT[(M)] [UNSIGNED] |
Supported, with differences |
MySQL requires 3 bytes to store MEDIUMINT data.
GaussDB maps data to the INT type and requires 4 bytes for storage.
For details about other differences, see Differences in terms of the integer types. |
INT[(M)] [UNSIGNED] |
Supported, with differences |
For details, see Differences in terms of the integer types. |
INTEGER[(M)] [UNSIGNED] |
Supported, with differences |
For details, see Differences in terms of the integer types. |
BIGINT[(M)] [UNSIGNED] |
Supported, with differences |
For details, see Differences in terms of the integer types. |
Arbitrary Precision Types
MySQL |
GaussDB |
Difference |
---|---|---|
DECIMAL[(M[,D])] |
Supported, with differences |
|
NUMERIC[(M[,D])] |
Supported, with differences |
|
DEC[(M[,D])] |
Supported, with differences |
|
FIXED[(M[,D])] |
Not supported |
- |
Floating-Point Types
MySQL |
GaussDB |
Difference |
---|---|---|
FLOAT[(M,D)] |
Supported, with differences |
|
FLOAT(p) |
Supported, with differences |
|
DOUBLE[(M,D)] |
Supported, with differences |
|
DOUBLE PRECISION[(M,D)] |
Supported, with differences |
|
REAL[(M,D)] |
Supported, with differences |
|
Sequential Integers
MySQL |
GaussDB |
Difference |
---|---|---|
SERIAL |
Supported, with differences |
For details about SERIAL in GaussDB, see "SQL Reference > Data Types > Value Types" in Developer Guide.
The differences in specifications are as follows:
CREATE TABLE test(f1 serial, f2 CHAR(20));
|
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot