Oracle study NOTE 2: datetime collection of data types

Source: Internet
Author: User
Tags informix

There is a question about the datetime data type in the 1z0-007 question bank:
Which three are datetime data types that can be used when specifying column definitions? (Choose Three)

A. Timestamp
B. interval month to day
C. interval day to second
D. interval year to month
E. timestamp with database timezone

The answer should be A, C, and D. However, in the Oracle9i reference, it seems that the interval is not included in the datetime PES ypes. The original text is described as follows:
The datetime datatypes are date, timestamp, timestamp with time zone and timestamp with local time zone. values of datetime datatypes are sometimes called "datetimes ". the interval datatypes are interval year to month and interval day to second. values of interval datatypes are sometimes called intervals.

Therefore, if three of the above questions are not specified, it is very likely to be wrong.

The date data type is used most often at work, generally including year, month, day, hour, minute, and second. However, date constants have never been used before, in the format of 'date' 2009-07-28 ', cannot contain the time section, and must be in the 'yyyy-MM-DD' format, if you want to include the time section, to_date can only be used for conversion.

The timestamp and interval data types are rarely used at work.
The timestamp is similar to the date value. It is only the second or less later. You can use 0-9 decimal places to indicate its precision (fractional_seconds_precision ). However, the difference is that the timestamp can be followed by the with time zone or with local time zone. The with Time Zone indicates that the data type also contains the time zone offset Information Between UTC and UTC. In the data type with local time zone, the data is stored as the database time zone, when you obtain data, Oracle calculates the time zone offset from UTC based on the time zone information in the local session.

I have never seen interval in my impressions. I may be referring to the interval data type in Informix. However, Oracle9i only has two types of interval: interval year to month and interval day to second, it is much simpler than Informix. After year, you can add an accuracy control. For example, if interval year (1) to month, the year part can be at most one digit, and the default value is 2; the same is true for the day part. For example, inetrval Day (3) to second indicates a maximum of three digits for the day part. The default value is 2. You can add the Time Precision below seconds after second, for example, inetrval Day (3) to second (3) indicates that the following part of the second is represented by three decimal places. Note that the number after this second is easy to understand as the second precision, which is actually the precision of the part below the second.
The constant expression of interval is similar to the following method:
Interval '3-1' year to month, indicating 3 years and 1 month, equivalent to interval '37' month, that is, 37 months
Interval '2 'Day to second, indicating 2 days and 1 hour.
Interval '2017 00:01:00. 100' Day (3) to second (3)

The interval data type can be added or subtracted from the date, timstamp data type. Two identical interval data types can also be added or subtracted, but the interval year to month and interval day to second data cannot be operated.

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/mosaic/archive/2009/07/28/4388851.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.