Date and Time Data Types
Data Type |
Differences Compared with MySQL |
---|---|
DATE |
None |
DATETIME[(fsp)] |
For details about the differences, see the description below the table. |
TIMESTAMP[(fsp)] |
GaussDB supports the TIMESTAMP data type. Compared with MySQL, GaussDB has the following differences in specifications:
|
TIME[(fsp)] |
GaussDB supports the TIME data type. Compared with MySQL, GaussDB has the following differences in specifications:
|
YEAR[(4)] |
GaussDB supports the YEAR data type. Compared with MySQL, GaussDB has the following differences in specifications: In MySQL 5.7, the YEAR column is displayed as YEAR(4) by default. GaussDB is consistent with MySQL 8.0, displaying only YEAR. |

- If you specify a precision for the DATETIME, TIME, or TIMESTAMP data type greater than the maximum precision supported by the data type, GaussDB truncates the precision to the maximum precision supported by the data type, whereas MySQL reports an error.
- In MySQL, when explicit_defaults_for_timestamp is set to off, the processing logic of the TIMESTAMP columns is as follows:
- If NULL or NOT NULL attribute is not explicitly specified for a column, the NOT NULL attribute will be automatically added. When a NULL value is inserted into such a column, the NULL value is replaced with the current timestamp.
- If the NULL attribute is not specified for the first TIMESTAMP column in a table, the DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP attributes will be automatically added to the column.
- If the NULL attribute is not specified for the second and subsequent TIMESTAMP columns in a table, the DEFAULT '0000-00-00 00:00:00' attribute will be automatically added to the columns.
- In MySQL, when explicit_defaults_for_timestamp is set to off, the processing logic of the TIMESTAMP columns is as follows:
- When a NULL value is inserted into a TIMESTAMP column, the NULL value is not replaced with the current timestamp.
- If NULL or NOT NULL attribute is not explicitly specified for a column, the NULL attribute will be automatically added.
- When a NULL value is inserted into a column with the NOT NULL attribute specified, an error is reported in strict mode, and '0000-00-00 00:00:00' is inserted in loose mode.
- DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP attributes will not be automatically added to any TIMESTAMP columns.
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