Relationship between SCN and TimeStamp in Oracle 10 GB

Source: Internet
Author: User

The following articles mainly introduce the contents of SCN and TimeStamp in Oracle 10g. We all know that in Oracle 10g, the function is used to convert the SCN and timestamp to improve the flash back operation. This article uses an example to analyze the function:

Example:

In step 1, we can use dbms_flashback.get_system_change_number to obtain the current SCN value of the system:

 
 
  1. SQL> col scn for 9999999999999  
  2. SQL> select dbms_flashback.get_system_change_number scn from dual;  
  3. SCN  
  4. 8908390522972  

Then, the scn_to_timestamp function can be used to convert the SCN to the timestamp:

 
 
  1. SQL> select scn_to_timestamp(8908390522972) scn from dual;  
  2. SCN  
  3. 05-JAN-07 10.56.30.000000000 AM  

Here, you can use timestamp_to_scn to convert the timestamp to SCN:

 
 
  1. SQL> select timestamp_to_scn(scn_to_timestamp(8908390522972)) scn from dual;  
  2. SCN  
  3. 8908390522972  

Through the above two functions, Oracle can establish the relationship between SCN and time. In versions earlier than 10 Gb of Oracle, the correspondence between SCN and time cannot be obtained through Function Conversion, generally, logs can only be obtained through logmnr analysis.

Note: This type of conversion depends on data records in the database, and cannot be converted for persistent SCN. For example:

 
 
  1. SQL> select min(FIRST_CHANGE#) scn,max(FIRST_CHANGE#) scn from v$archived_log;  
  2. SCN SCN  
  3. 8907349093953 8908393582271  
  4. SQL> select scn_to_timestamp(8907349093953) scn from dual;  
  5. select scn_to_timestamp(8907349093953) scn from dual  
  6. *  
  7. ERROR at line 1:  
  8. ORA-08181: specified number is not a valid system change number  
  9. ORA-06512: at "SYS.SCN_TO_TIMESTAMP", line 1  
  10. ORA-06512: at line 1  
  11. SQL> select scn_to_timestamp(8908393582271) scn from dual;  
  12. SCN   

The above content is the description of SCN and TimeStamp in Oracle 10g, hoping to help you in this aspect.

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.