Oracle memiliki SCN (Nomor Perubahan Sistem):http://docs.Oracle.com/cd/E11882_01/server.112/e10713/transact.htm#CNCPT039
Gunakan pseudocolumn ORA_ROWSCN untuk memeriksa SCN baris saat ini:
http://docs.Oracle.com/cd/B28359_01/server.111/b28286/pseudocolumns007.htm#SQLRF51145
Contoh:
SELECT ora_rowscn, t.* From test t;
Demo --> http://www.sqlfiddle.com/#!4/535bc /1
(Pada SQLFiddle, komit eksplisit tampaknya tidak berfungsi - pada database nyata setiap komit meningkatkan SCN).
Contoh pada database "nyata":
CREATE TABLE test(
id int,
value int
);
INSERT INTO test VALUES(1,0);
COMMIT;
SELECT ora_rowscn, t.* FROM test t;
ORA_ROWSCN ID VALUE
---------- ---------- ----------
3160728 1 0
UPDATE test SET value = value + 1 WHERE id = 1;
COMMIT;
SELECT ora_rowscn, t.* FROM test t;
ORA_ROWSCN ID VALUE
---------- ---------- ----------
3161657 1 1
UPDATE test SET value = value + 1 WHERE id = 1;
COMMIT;
SELECT ora_rowscn, t.* FROM test t;
ORA_ROWSCN ID VALUE
---------- ---------- ----------
3161695 1 2
Jika SCN transaksi diketahui, kita dapat menggunakan kueri kilas balik untuk mendapatkan nilai masa lalu dari baris tersebut:
http://docs.Oracle.com/cd/B28359_01/appdev.111/b28424/adfns_flashback.htm#g1026131
Contoh:
SELECT t.*,
versions_startscn, versions_starttime,
versions_endscn, versions_endtime,
versions_xid, versions_operation
FROM test VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE t;
ID VALUE VERSIONS_STARTSCN VERSIONS_STARTTIME VERSIONS_ENDSCN VERSIONS_ENDTIME VERSIONS_XID VERSIONS_OPERATION
---------- ---------- ----------------- ------------------- --------------- ------------------- ---------------- ------------------
1 2 3161695 13/12/10 08:19:39 06000300EA070000 U
1 1 3161657 13/12/10 08:18:39 3161695 13/12/10 08:19:39 06001200EA070000 U
1 0 3161657 13/12/10 08:18:39
SELECT t.*,
versions_startscn, versions_starttime,
versions_endscn, versions_endtime,
versions_xid, versions_operation
FROM test VERSIONS BETWEEN SCN 3161657 AND 3161657 t;
ID VALUE VERSIONS_STARTSCN VERSIONS_STARTTIME VERSIONS_ENDSCN VERSIONS_ENDTIME VERSIONS_XID VERSIONS_OPERATION
---------- ---------- ----------------- ------------------- --------------- ------------------- ---------------- ------------------
1 1 3161657 13/12/10 08:18:39 06001200EA070000 U