I recently learnt that oracle has a feature which was pretty useful to me - as the designer/implementator didn't care much about data history - I can query the historical state of a record if it's available yet in the oracle cache, like this:
select *
from ( select *
from sometable where some_condition )
as of timestamp sysdate-1
But now I need to check the historical data within a range. Is it possible anyhow, using the cache?
Yes, like this:
Note that how far back you can go is limited by the UNDO_RETENTION parameter, and will typically be hours rather than days.
One note to be aware of is that this sort of flashback query relies on UNDO information that is written to the UNDO tablespace. And that information is not retained forever-- most production systems under reasonable load are not going to have 24 hours of UNDO information available.
Depending on the Oracle version, you may need to set the
UNDO_RETENTION
parameter to a value longer than the time period you are trying to flashback through.will give you all versions of all rows in the last day.
There's lots more you can do with this. Check out the documentation (you may want to find the docs for your version).