是否可以找到在Oracle数据库的表中创建特定行的日期。 (在列中未插入创建日期时间)。
答案 0 :(得分:1)
您可以在查询中使用ORA_ROWSCN伪列。看:
SELECT SCN_TO_TIMESTAMP(ORA_ROWSCN), last_name FROM employees
WHERE employee_id = 188;
还请查看有关以下内容的文档:https://docs.oracle.com/cd/B19306_01/server.102/b14200/pseudocolumns007.htm
答案 1 :(得分:0)
如果在Oracle RDBMS上启用了插入日志/审计功能,则可以。
AUDIT INSERT, UPDATE, DELETE ON MySchema.MyTable BY ACCESS;
然后开始审核日志以进行记录。此刻之后,您可以从
查询select * from sys.aud$
答案 2 :(得分:0)
例如1.插入。使用闪回功能。
insert into test2(p1,p2,p3)
values(1,'test_insert','test')
==>
1 row(s) inserted
SELECT versions_xid XID, versions_startscn START_SCN,
versions_endscn END_SCN, versions_operation OPERATION,
p1, p2, p3, ROWIDTOCHAR(ROWID)
FROM manager.test2
VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE;
XID, START_SCN, END_SCN, OPERATION, p1, p2, p3, ROWIDTOCHAR(ROWID)
04000A0054FD0A00 1404377619968 I 1 test_insert test AAA2wgAAbAAAAEsAAO
22 AAA2wgAAbAAAAEsAAA
24 AAA2wgAAbAAAAEsAAB
54 AAA2wgAAbAAAAEsAAC
10 AAA2wgAAbAAAAEsAAD
10 test2 test1 AAA2wgAAbAAAAEsAAE
225 test10 AAA2wgAAbAAAAEsAAF
225 test10 AAA2wgAAbAAAAEsAAG
225 test10 AAA2wgAAbAAAAEsAAH
225 test10 AAA2wgAAbAAAAEsAAI
225 test10 AAA2wgAAbAAAAEsAAJ
225 test10 AAA2wgAAbAAAAEsAAK
225 test10 test4 AAA2wgAAbAAAAEsAAL
225 test10 test4 AAA2wgAAbAAAAEsAAM
50 test insert test AAA2wgAAbAAAAEsAAN
SQL> SELECT SCN_TO_TIMESTAMP('1404377619968') FROM dual;
SCN_TO_TIMESTAMP('1404377619968')
---------------------------------------------------------------------------
25.01.19 07:32:12,000000000
SELECT SCN_TO_TIMESTAMP(ORA_ROWSCN),p1,p2,p3 FROM test2
25.01.19 07:32:12,000000000 22
25.01.19 07:32:12,000000000 24
25.01.19 07:32:12,000000000 54
25.01.19 07:32:12,000000000 10
25.01.19 07:32:12,000000000 10 test2 test1
25.01.19 07:32:12,000000000 225 test10
25.01.19 07:32:12,000000000 225 test10
25.01.19 07:32:12,000000000 225 test10
25.01.19 07:32:12,000000000 225 test10
25.01.19 07:32:12,000000000 225 test10
25.01.19 07:32:12,000000000 225 test10
25.01.19 07:32:12,000000000 225 test10 test4
25.01.19 07:32:12,000000000 225 test10 test4
25.01.19 07:32:12,000000000 50 test insert test
25.01.19 07:32:12,000000000 1 test_insert test
例如2.Update。使用闪回功能。
CREATE TABLE manager.test2
(p1 NUMBER,
p2 VARCHAR2(200 BYTE),
p3 VARCHAR2(100 BYTE)
)
select * from test2;
p1 p2 p3
---------- --------------- --------
22
24
54
124
124 test2 test1
225 test10
225 test10
225 test10
225 test10
225 test10
225 test10
225 test10 test4
225 test10 test4
update test2 set p1=10 where p1=124
==>
2 row(s) updated
SELECT versions_xid XID, versions_startscn START_SCN,
versions_endscn END_SCN, versions_operation OPERATION,
p1, p2, p3, ROWIDTOCHAR(ROWID)
FROM manager.test2
VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE;
XID, START_SCN, END_SCN, OPERATION, p1, p2, p3, ROWIDTOCHAR(ROWID)
07000F0051030B00 1404163252291 U 10 test2 test1 AAA2wgAAbAAAAEsAAE
07000F0051030B00 1404163252291 U 10 AAA2wgAAbAAAAEsAAD
22 AAA2wgAAbAAAAEsAAA
24 AAA2wgAAbAAAAEsAAB
54 AAA2wgAAbAAAAEsAAC
1404163252291 124 AAA2wgAAbAAAAEsAAD
1404163252291 124 test2 test1 AAA2wgAAbAAAAEsAAE
225 test10 AAA2wgAAbAAAAEsAAF
225 test10 AAA2wgAAbAAAAEsAAG
225 test10 AAA2wgAAbAAAAEsAAH
225 test10 AAA2wgAAbAAAAEsAAI
225 test10 AAA2wgAAbAAAAEsAAJ
225 test10 AAA2wgAAbAAAAEsAAK
225 test10 test4 AAA2wgAAbAAAAEsAAL
225 test10 test4 AAA2wgAAbAAAAEsAAM
SQL> SELECT SCN_TO_TIMESTAMP('1404163252291') FROM dual;
SCN_TO_TIMESTAMP('1404163252291')
--------------------------------------------------------------------------
24.01.19 14:08:27,000000000
SELECT xid, start_scn , commit_scn COMMIT,operation OP, logon_user ,undo_sql FROM flashback_transaction_query
WHERE xid = HEXTORAW('07000F0051030B00');
07000F0051030B00 1404163252288 1404163252291 UPDATE MANAGER update "MANAGER"."TEST2" set "P1" = '124' where ROWID = 'AAA2wgAAbAAAAEsAAE';
07000F0051030B00 1404163252288 1404163252291 UPDATE MANAGER update "MANAGER"."TEST2" set "P1" = '124' where ROWID = 'AAA2wgAAbAAAAEsAAD';
07000F0051030B00 1404163252288 1404163252291 BEGIN MANAGER