OceanBase Database supports the following datetime 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 datetime data types supported in the current version of OceanBase Database in detail.
| 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 | Datetime 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 | Datetime 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.