Numeric Data Types
No. |
MySQL |
GaussDB |
Difference |
---|---|---|---|
1 |
BOOL |
Not fully compatible. |
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. |
2 |
BOOLEAN |
Not fully compatible. |
|
3 |
TINYINT[(M)] [UNSIGNED] |
Supported |
For details, see the following note. |
4 |
SMALLINT[(M)] [UNSIGNED] |
Supported |
For details, see the following note. |
5 |
MEDIUMINT[(M)] [UNSIGNED] |
Supported |
MySQL requires 3 bytes to store MEDIUMINT data.
GaussDB maps data to the INT type and requires 4 bytes for storage.
For other differences, see the following note. |
6 |
INT[(M)] [UNSIGNED] |
Supported |
For details, see the following note. |
7 |
INTEGER[(M)] [UNSIGNED] |
Supported |
For details, see the following note. |
8 |
BIGINT[(M)] [UNSIGNED] |
Supported |
For details, see the following note. |
- Input formats:
- MySQL
For characters such as "asbd", "12dd", and "12 12", the system truncates them or returns 0 and reports a WARNING message. 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 *
- Explicit 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.
No. |
MySQL |
GaussDB |
Difference |
---|---|---|---|
1 |
DECIMAL[(M[,D])] |
Supported |
|
2 |
NUMERIC[(M[,D])] |
Supported |
|
3 |
DEC[(M[,D])] |
Supported |
|
4 |
FIXED[(M[,D])] |
Not supported |
- |
No. |
MySQL |
GaussDB |
Difference |
---|---|---|---|
1 |
SERIAL |
Not fully compatible. |
For details about SERIAL, see Developer Guide in GaussDB.
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