下面我们来观察无条件限制表级补全日志的具体表现: alter database drop supplemental log data (primary key,unique index) columns;
alter table test add supplemental log data (primary key,unique index) columns;
update test set t2=’ZZZZZ’; commit;
使用LOGMNR工具查看redo中的SQL: update “SYS”.”TEST” set “T2” = ‘ZZZZZ’ where “T1” = ‘TEST’ and “T2” = ‘AAAAA’ and “T3” = ‘TEST’………
可以发现where子句之后包含了所有列值。
delete test; commit;
使用LOGMNR工具查看redo中的SQL:
delete from “SYS”.”TEST” where “T1” = ‘TEST’ and “T2” = ‘ZZZZZ’ and “T3” = ‘TEST’ and “T4” = ‘TEST’ and “T5” ……
delete操作同样在where子句之后包含了所有列值。
又我们可以针对表上字段建立特定的补全日志组,以减少where子句后列值的出现。
alter table test drop supplemental log data (primary key,unique index) columns; –关闭表上原先的补全日志
alter table test add supplemental log group test_lgp (t1 ,t2,t3,t4,t5,t6,t12,t250) always; –创建补全日志组
update test set t2=’XXXXX’ ; commit;
使用LOGMNR工具查看redo中的SQL:
update “SYS”.”TEST” set “T2” = ‘XXXXX’ where “T1” = ‘TEST’ and “T2” = ‘TEST’ and “T3” = ‘TEST’ and “T4” = ‘TEST’ and “T5” = ‘TEST’ and “T6” = ‘TEST’ and “T12” = ‘TEST’ and “T250” = ‘TEST’ and ROWID = ‘AAAMieAABAAAOhnAAA’;
如上所示重做日志中正确地显示了UPDATE操作中用户指定的字段值。
delete test;
使用LOGMNR工具查看redo中的SQL:
delete from “SYS”.”TEST” where “T1” = ‘TEST’ and “T2” = ‘XXXXX’ and “T3” = ‘TEST’ ……