Understanding the INTERVAL data type
INTERVAL
data types are available to model the duration. There are two types based on granularity precision: dealing with the year and month precision (the first type) or digging deeper into time elements (the second type).
INTERVAL YEAR TO MONTH
INTERVAL YEAR TO MONTH
consists of no more than two elements describing the year and month delimited by a dash (-
). After the definition, the format is specified, with the optional specification of precision. Figure 5.4 shows the syntax in graphical form. The first format element is mandatory, and the second is optional. Note that the default precision is 2
, if not specified explicitly.
Figure 5.4 – INTERVAL YEAR TO MONTH
Table 5.2 shows examples of INTERVAL YEAR TO MONTH
usage. The definition can be used independently or associated with the DATE
or TIMESTAMP
value, typically expressing the beginning point of the validity. The general definition consists of year...