的时间戳。它又分为两种模式:一种是基于block这是默认的模式(块级跟踪,非行依赖性(NOROWDEPENDENCIES));还有一种是基于row上,这种模式只能在建里表时指定ROWDEPENDENCIES(行级跟踪),不可以通过后期的alter
在10g之前,很多系统要实现增量数据抽取,要么通过解析日志,要么加触发器,要么就在表上加一个时间截字段。ORA_ROWSCN其实就是第三种方式,只是这个字段由Oracle来维护,这样可以避免一些应用绕过时间截去更新其他字段带来的问题。
下面是官方说明:
NOROWDEPENDENCIES | ROWDEPENDENCIES
This clause lets you specify whether table will use row-level dependency tracking.
With this feature, each row in the table has a system change number (SCN) that
represents a time greater than or equal to the commit time of the last transaction that
modified the row. You cannot change this setting after table is created.
ROWDEPENDENCIES
dependency tracking. This setting is useful primarily to allow for parallel propagation
in replication environments. It increases the size of each row by 6 bytes.
NOROWDEPENDENCIES
to use the row-level dependency tracking feature. This is the default.
SQL> select * from global_name; GLOBAL_NAME -------------------------------------------------------------------------------- www.oracledatabase12g.com SQL> select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi PL/SQL Release 10.2.0.4.0 - Production CORE 10.2.0.4.0 Production TNS for Linux: Version 10.2.0.4.0 - Production NLSRTL Version 10.2.0.4.0 - Production SQL> drop table maclean; Table dropped. SQL> create table maclean(t1 int,t2 timestamp) ; Table created. SQL> insert into maclean values(1,systimestamp); 1 row created. SQL> commit; Commit complete. SQL> insert into maclean values(2,systimestamp); 1 row created. SQL> commit; Commit complete. SQL> alter session set nls_timestamp_format='hh24:mi:ss'; Session altered. SQL> col t2 for a35 SQL> col orscn for a35 SQL> select scn_to_timestamp(ora_rowscn) orscn,t2 from maclean; ORSCN T2 ----------------------------------- ----------------------------------- 20:30:11 20:29:56 20:30:11 20:30:10 create table maclean_rd(t1 int,t2 timestamp) rowdependencies; Table created. SQL> select table_name,dependencies from user_tables where dependencies!='DISABLED'; TABLE_NAME DEPENDEN ------------------------------ -------- MACLEAN_RD ENABLED SQL> insert into maclean_rd values(1,systimestamp); 1 row created. SQL> commit; Commit complete. SQL> insert into maclean_rd values(2,systimestamp); 1 row created. SQL> commit; Commit complete. SQL> select scn_to_timestamp(ora_rowscn) orscn,t2 from maclean_rd; ORSCN T2 ----------------------------------- ----------------------------------- 20:31:26 20:31:25 20:31:35 20:31:37 SQL> select dbms_rowid.rowid_relative_fno(rowid),dbms_rowid.rowid_block_number(rowid) from maclean_rd; DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID) DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) ------------------------------------ ------------------------------------ 1 94122 1 94122 SQL> alter system dump datafile '/s01/10gdb/oradata/CLINICA/datafile/o1_mf_system_6fp8d3f0_.dbf' block 94122; System altered. SQL> oradebug setmypid; Statement processed. SQL> oradebug tracefile_name; /s01/10gdb/admin/clinica/udump/clinica_ora_12934.trc block_row_dump: tab 0, row 0, @0x1f88 tl: 24 fb: --H-FL-- lb: 0x0 cc: 2 dscn 0x0000.0351b8bd col 0: [ 2] c1 02 col 1: [11] 78 6f 01 02 15 20 1a 21 d8 52 68 tab 0, row 1, @0x1f70 tl: 24 fb: --H-FL-- lb: 0x0 cc: 2 dscn 0x0000.0351b8c4 col 0: [ 2] c1 03 col 1: [11] 78 6f 01 02 15 20 26 02 ab c2 f8 SQL> alter table maclean move tablespace users ROWDEPENDENCIES; alter table maclean move tablespace users ROWDEPENDENCIES * ERROR at line 1: ORA-14133: ALTER TABLE MOVE cannot be combined with other operations