Oracle includes built-in features that allow you to convert scn into timestamp or timestamp to SCN. SCN_TO_TIMESTAMP accepts as an argument a number which evaluates to a system number (SCN) and returns the approximate timestamp associated. This function can be used to find the approximate timestamp associated an SCN. Oracle provides two packages, TIMESTAMP_TO_SCN and SCN_TO_TIMESTAMP. convert scn to a timestamp.
- When you are working on RMAN Recovery, SCN is crucial.
- Archivelog gap resolution, Recovery of Physical standby servers
- You can use it in a FLASHBACK_SCN data pump export parameter file to maintain a consistent copy at any given point-in time.
Table of Contents
Convert SCN to a Timestamp
Follow the below steps.
How to find the Current SCN number
Use the below query to find the current SCN number.
SQL>select current_scn from v$database;
OR
SQL>select to_char(current_scn) SCN from v$database;
SCN
--------------
9799126476110
Check Timestamp Against SCN
Using the below query you can find out the timestamp against the SCN.
SQL> select scn_to_timestamp(9799126476110) as timestamp from dual;
TIMESTAMP
-----------------------------------------
15-JUN-22 01.56.33.000000000 AM
Find the SCN against the timestamp
Find SCN against timestamp using the below query:
SQL>select timestamp_to_scn(to_timestamp('15-JUN-22 01.56.33','DD-MON-YY HH24:MI:SS')) AS scn from dual;
SCN
----------------------------------------
9799126464266
Read more from the rider
- How to Setup Oracle to Startup Automatically if the System is Restarted
- How to check when last stats was gathered in Oracle?
- Oracle RMAN Tutorial
- Install Linux in Oracle VirtualBox
- Resolve error in invoking target agent nmhs of makefile
- Purge RECYCLEBIN in Oracle