Convert TIMESTAMP to SCN and SCN to TIMESTAMP in Oracle

Convert TIMESTAMP to SCN and SCN to TIMESTAMP in Oracle

In many recovery scenario we need to know our SCN and timestamps.
We can convert this by using the following function
SCN_TO_TIMESTAMP
TIMESTAMP_TO_SCN

We can use this function with help of dual functions.

Example of using this function as follows:

1. Convert the SCN to Timestamp

SQL> select scn_to_timestamp(2011955) from dual;

SCN_TO_TIMESTAMP(2011955)
-----------------------------------------------------
05-SEP-18 12.46.20.000000000 PM

2. Convert the Timestamp to SCN

SQL> select timestamp_to_scn(to_timestamp('05-09-2018 12:46:21','dd-mm-yyyy hh24:mi:ss')) scn from dual;

SCN
----------
2011955

Advertisements

One thought on “Convert TIMESTAMP to SCN and SCN to TIMESTAMP in Oracle

  1. Pingback: Restore table data with Flashback Query in Oracle | Smart way of Technology

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.