Skip to Main Content
  • Questions
  • ora_rowscn - is it always incremental,

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Shiva.

Asked: June 27, 2018 - 7:32 pm UTC

Last updated: July 01, 2018 - 4:58 am UTC

Version: 11.2.0.4

Viewed 1000+ times

You Asked

Hello,

I want to sqoop data out of my Oracle 11.2 database on a daily basis. However, I want to do only incremental extracts. Apparently, scn_to_timestamp doesn't always work due to ORA-08181: specified number is not a valid system change number.

Instead, can I use ora_rowscn? This is possible only if ora_rowscn always increases from its previous value.

Day I: select min(ora_rowscn) into minoraRowscn from gsa.tablename;
Day 1: select * from gsa.tablename where ora_rowscn> minoraRowscn
Day 1: select max(ora_rowscn) into previousOraRowscn from gsa.tablename;
Day2: Select * from gsa.tablename where ora_rowscn >= previousOraRowscn
Day 3: Keeps going on..

If the above process gives me some duplicate rows, it's fine. However, is it reliable approach to extract incremental data?

Note: if a table is truncated, I guess ora_rowscn resets completely to a different value. We will handle that by reading the entire table.


Thanks,


and Connor said...

It *might* work, but my thoughts are the risk profile is too high because we do *whatever we like* with the SCN number. It is out of your control.

For example, *already* we do the following:

- Sometimes we stamp the change SCN on the block as you make the change
- Sometimes we stamp the change SCN on the block much later, when someone else queries that block
- Sometimes we stamp a *totally* different SCN on the block much later.

And one day, we could easily come up with 10 brand new ways in which we use/update/modify the SCN on rows and blocks purely to suit *our* needs.

So how would you *ever* be confident that

a) you've tested every use case?
b) applying a patch to the database won't totally break your solution, and possible leave it unsolvable ?

Check out this thread - it is a long read, but ultimately arrives on a solution to pick up deltas in an efficient way without locking tables.

https://asktom.oracle.com/pls/asktom/asktom.search?tag=selecting-rows-that-have-changed-via-timestamp-problematic-with-non-blocking-reads





Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database