ORACLE查询某个时间之前的记录,与现在的记录的sql

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/KindergartenBoss/article/details/82193873

记录一下,防止自己忘记

-- 查询的是现在的某条记录 与 3分钟之前这条记录的数据

select * from sysuser  where id ='fa5224f9024d431c97ce653910ab9289'
union all 
select * from sysuser as of timestamp (systimestamp - interval '3' minute) where id = 'fa5224f9024d431c97ce653910ab9289' --查找sysuser表中300分钟之前的数据
 

-- 根据秒、小时、天数  查询数据

select * from sysuser as of timestamp (systimestamp - interval'4' second) where id = 'fa5224f9024d431c97ce653910ab9289' --查找sysuser表中600秒之前的数据

select * from sysuser as of timestamp (systimestamp - interval '2'hour) where id = 'fa5224f9024d431c97ce653910ab9289'--查找sysuser表中3小时之前的数据

select * from sysuser as of timestamp (systimestamp - interval '1'day) where id = 'fa5224f9024d431c97ce653910ab9289'--查找sysuser表中1天之前的数据
 

每天进步一点点,加油!

猜你喜欢

转载自blog.csdn.net/KindergartenBoss/article/details/82193873