Oracle12C #3 查看数据修改历史记录

下面两种方式:

1、查询表指定时间之前的数据记录

SELECT * from [表名] AS OF TIMESTAMP TO_TIMESTAMP('2020-8-6 17:00:00','yyyy-mm-dd hh24:mi:ss');

eg:
SELECT * from NEQ_LOT AS OF TIMESTAMP TO_TIMESTAMP('2020-8-6 17:00:00','yyyy-mm-dd hh24:mi:ss');

2、 查询表指定时间段内的修改记录

SELECT 被修改表字段,VERSIONS_STARTTIME,VERSIONS_ENDTIME,VERSIONS_OPERATION FROM 表 VERSIONS 
BETWEEN TIMESTAMP MINVALUE AND MAXVALUE WHERE VERSIONS_STARTTIME IS NOT NULL 
ORDER BY VERSIONS_STARTTIME DESC;

eg:
SELECT rec, recnum, VERSIONS_STARTTIME,VERSIONS_ENDTIME,VERSIONS_OPERATION  FROM NEQ_LOT_DETAILS VERSIONS 
BETWEEN TIMESTAMP TO_TIMESTAMP('2020-8-5 00:00:00','yyyy-mm-dd hh24:mi:ss') AND TO_TIMESTAMP('2020-8-13 23:59:59','yyyy-mm-dd hh24:mi:ss') 
WHERE id = 'dc999019-0716-4364-9e0c-52bbe2bba058'
ORDER BY VERSIONS_STARTTIME DESC;

第二种方式数据量大的时候查询会比较慢,所以要把握好时间跨度!

你可能感兴趣的:(#,Oracle,oracle)