OceanBase Database supports the following date and time data types: DATE, TIME, DATETIME, TIMESTAMP, and YEAR. Each data type has a valid value range and a "zero" value that is used to specify any invalid value.
The following table describes the date and time data types supported in the current version of OceanBase Database in detail.
| Data type | Format | Lower bound | Upper bound | Description |
|---|---|---|---|---|
DATETIME |
YYYY-MM-DD HH:MM:SS[.fraction] | 0000-00-00 00:00:00.000000 | 9999-12-31 23:59:59.999999 | Date and time (exclusive of the time zone) |
TIMESTAMP |
YYYY-MM-DD HH:MM:SS[.fraction] | 0000-00-00 00:00:00.000000 | 9999-12-31 23:59:59.999999 | Date and time (inclusive of the time zone |
DATE |
YYYY-MM-DD | 0000-00-00 | 9999-12-31 | Date |
TIME |
HH:MM:SS[.fraction] | -838:59:59.000000 | 838:59:59.000000 | Time |
YEAR |
YYYY | 1901 | 2155 | Year |
The value range and precision of DATETIME, TIMESTAMP, and TIME depend on their scale. Scale is an attribute that specifies the maximum number of valid digits in the fractional part. The maximum value is 6, and the default value is 0.