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

Source: Internet
Author: User

The following describes the TIMESTAMP type.
Create table test_time (col_time timestamp );
 
 
SQL> insert into test_time values (to_timestamp ('2017-1-1. 0', 'syyyy-mm-dd hh24: mi: ss. ff '));
 
One row has been created.
 
SQL> insert into test_time values (to_timestamp ('2017-1-1. 0', 'syyyy-mm-dd hh24: mi: ss. ff '));
 
One row has been created.
 
SQL> insert into test_time values (to_timestamp ('2017-12-31 23:59:59. 000000', 'syyyy-mm-dd hh24: mi: ss. ff '));
 
One row has been created.
 
SQL> insert into test_time values (to_timestamp ('-0001-1-1. 0', 'syyyy-mm-dd hh24: mi: ss. ff '));
 
One row has been created.
 
SQL> insert into test_time values (to_timestamp ('-0100-3-4. 234015', 'syyyy-mm-dd hh24: mi: ss. ff '));
 
One row has been created.
 
SQL> insert into test_time values (systimestamp );
 
One row has been created.
 
SQL> insert into test_time values (to_timestamp ('2017-1-1. 100', 'syyyy-mm-dd hh24: mi: ss. ff9 '));
 
One row has been created.
 
SQL> commit;
 
Submitted.
 
SQL> select to_char (col_time, 'syyyy-mm-dd hh24: mi: ss. ff9') time, dump (col_time) dump_time
2 from test_time;
 
TIME DUMP_TIME
----------------------------------------------------------------------------------
0001-01-01 00:00:00. 000000000 Typ = 180 Len = 7: 100,101, 1
00:00:00. 000000000 Typ = 180 Len = 7: 120,100, 1
9999-12-31 23:59:59. 999999000 Typ = 180 Len = 11: 199,199, 154,198, 24
-0001-01-01 00:00:00. 000000000 Typ = 180 Len = 7:, 99, 1
-0100-03-04 13:02:03. 234015000 Typ = 180 Len = 11: 99,100, 242,201, 24
16:14:52. 738000000 Typ = 180 Len = 11: 120,104, 252,252,128
00:00:00. 123457000 Typ = 180 Len = 11: 120,100, 91,205,232
 
 
Compared with the DATE type, we can find that if the TIMESTAMP type does not contain microsecond information or the microsecond value is 0, the storage result is exactly the same as the DATE type. When the microsecond value is 0, Oracle does not save microsecond information to save space.
 
If the millisecond value is not 0, Oracle saves the microsecond value as a 9-digit number.
 
For example, 999999000 is saved as 59,154,198 and 24. 234015000 Save As 13,242,201, 24.
 
SQL> select to_char (999999000, 'xxxxxxxxxx') from dual;
 
TO_CHAR (999
-----------
3b9ac618
 
SQL> select to_number ('3b ', 'xxx') one, to_number ('9a', 'xxx') two,
2 to_number ('c6 ', 'xxx') three, to_number ('18', 'xxx') four from dual;
 
ONE TWO THREE FOUR
----------------------------------------
59 154 198 24
 
SQL> select to_char (234015000, 'xxxxxxxx') from dual;
 
TO_CHAR (2
---------
Df2c918
 
SQL> select to_number ('D', 'xxx') one, to_number ('F2', 'xxx') two,
2 to_number ('c9 ', 'xxx') three, to_number ('18', 'xxx') four from dual;
 
ONE TWO THREE FOUR
----------------------------------------
13 242 201 24
 

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.