Oracle basic data type ----- (date type 3)

Source: Internet
Author: User

The date format stored in the database is different from the date format in SQL.
SQL> insert into test_date values (to_date ('2017-12-17 16:42:42 ', 'syyyy-mm-dd hh24: mi: ss '));
 
 
One row has been created.
 
SQL> select to_char (date_col, 'syyyy-mm-dd hh24: mi: ss') dat, dump (date_col) dump_date from test_date;
 
 
DAT DUMP_DATE
-----------------------------------------------------------------------------
16:42:42 Typ = 12 Len = 7: 120,104, 43
SQL> select to_char (to_date ('2017-12-17 16:42:42 ', 'syyyy-mm-dd hh24: mi: ss'), 'syyyy-mm-dd hh24: mi: ss') dat,
2 dump (to_date ('2017-12-17 16:42:42 ', 'syyyy-mm-dd hh24: mi: ss') dump_date from dual;
 
 
DAT DUMP_DATE
-----------------------------------------------------------------------------
16:42:42 Typ = 13 Len = 8: 212,7, 12,17, 16,42, 0
The results are quite different! So the storage methods are different!
The storage difference between the two is: 1) century, 2) hour, minute, and second
The dates in SQL are stored in numeric values. For example: 212 + 7*256 = 2004
SQL> select to_char (to_date ('-2004-12-17 16:42:42', 'syyyy-mm-dd hh24: mi: ss'), 'syyyy-mm-dd hh24: mi: ss ') dat,
2 dump (to_date ('-2004-12-17 16:42:42', 'syyyy-mm-dd hh24: mi: ss') dump_date from dual;
 
 
DAT DUMP_DATE
-----------------------------------------------------------------------
-16:42:42 Typ = 13 Len = 8: 44,248
In SQL, the maximum value of the first digit of a date is 256, and the maximum value of the second digit is 255. In addition, BC is complementary to that of the second digit.

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.