15 Ekim 2014 Çarşamba

AS OF TIMESTAMP

This is a very useful sql code to retrieve older data which is deleted.

sys.sample_table is a custom table created by sys user.


select *
from sys.sample_table as of timestamp (systimestamp - interval '10' minute);

select *
from sys.sample_table as of timestamp (systimestamp - interval '10' day);


select *
from sys.sample_table as of timestamp (sysdate -1);     -- 1 day ago 

select *
from sys.sample_table as of timestamp (sysdate - 1/24);   --1 hour ago

select *
from sys.sample_table as of timestamp (sysdate -1/(24*60));     -- 1 minute ago

select *
from sys.sample_table as of timestamp (sysdate - 1/(24*60*60));  --1 second ago



It is also good to see result by testing with these sql below and how it works;

select sysdate , (sysdate + 1)  from dual;  -- 1 day later

select sysdate, (sysdate + 1/24) from dual; --1 hour later

select sysdate, (sysdate + 1/(24*60)) from dual; --1 minute later

select sysdate, (sysdate + 1/(24*60*60)) from dual; --1 second later




There are also two different errors prompted while using 




1-)There is one day difference between these two select statements. What causes these two different errors?

select * 
from sys.sample_table as of timestamp (systimestamp - interval '5' day);

ORA - 01466

select *
from from sys.sample_table as of timestamp (systimestamp - interval '6' day);

ORA - 08180



Hiç yorum yok:

Yorum Gönder