主键冲突了,语句是不是还会被写入redo?
考虑这种情况
insert into t values (8,'eight');
insert into t values(9,'nine');
insert into t values(10,'ten');
insert into t values(11,'ten');
insert into t values(12,'ten');
如果上面的语句 有一条发生了类似主键错误,那么我们怎么能知道是哪一条呢。
答案。。 通过logminer 可以看到。
SQL> SELECT TO_CHAR(TIMESTAMP,'YYYY-MM-DD HH24:MI:SS') AS TIME , USERNAME , SQL_REDO,TABLE_name , rollback FROM V$LOGMNR_CONTENTS WHERE table_name='TEST_LOGMNR' ORDER BY TIME; TIME USERNAME SQL_REDO TABLE_NAME ROLLBACK ------------------- -------- -------------------------------------------------------------------------------- -------------------------------- ---------- 2013-04-19 16:21:36 SYS create table test_logmnr (id number, val varchar2(10)); TEST_LOGMNR 0 2013-04-19 16:21:56 SYS alter table test_logmnr add constraint tl_pk primary key (id); TEST_LOGMNR 0 2013-04-19 16:22:11 SYS insert into "SYS"."TEST_LOGMNR"("ID","VAL") values ('1','first'); TEST_LOGMNR 0 2013-04-19 16:22:23 SYS insert into "SYS"."TEST_LOGMNR"("ID","VAL") values ('2','second'); TEST_LOGMNR 0 2013-04-19 16:22:56 SYS insert into "SYS"."TEST_LOGMNR"("ID","VAL") values ('3','third'); TEST_LOGMNR 0 2013-04-19 16:23:05 SYS insert into "SYS"."TEST_LOGMNR"("ID","VAL") values ('2','second'); TEST_LOGMNR 0 2013-04-19 16:23:05 SYS delete from "SYS"."TEST_LOGMNR" where ROWID = 'AABF6MAABAAAR+CAAD'; TEST_LOGMNR 1 2013-04-19 16:32:52 SYS insert into "SYS"."TEST_LOGMNR"("ID","VAL") values ('2','second'); TEST_LOGMNR 0 2013-04-19 16:32:52 SYS delete from "SYS"."TEST_LOGMNR" where ROWID = 'AABF6MAABAAAR+CAAD'; TEST_LOGMNR 1 2013-04-19 16:33:31 SYS insert into "SYS"."TEST_LOGMNR"("ID","VAL") values ('8','second'); TEST_LOGMNR 0
比如上面查到的结果中,rollback 前面的一条语句就是出错的。