ora_rowscn

***ora_rowscn store
By default, ORA_ROWSCN is stored at the block level, not at the row level. It is only stored at the row level if the table was originally built with ROWDEPENDENCIES enabled. Assuming that you can fit many rows of your table in a single block and that you're not using the APPEND hint to insert the new data above the existing high water mark of the table, you are likely inserting new data into blocks that already have some existing data in them. By default, that is going to change the ORA_ROWSCN of every row in the block causing your query to count more rows than were actually inserted.

For detail please refer to https://stackoverflow.com/questions/9520995/understanding-the-ora-rowscn-behavior-in-oracle

***demonstration on ora_rowscn change on block level
1.Check the ora_rowscn for scott.emp table


SQL> select ora_rowscn,empno,ename from scott.emp;

ORA_ROWSCN      EMPNO ENAME
---------- ---------- ----------
    940347       7369 SMITH
    940347       7499 ALLEN
    940347       7521 WARD
    940347       7566 JONES
    940347       7654 MARTIN
    940347       7698 BLAKE
    940347       7782 CLARK
    940347       7788 SCOTT
    940347       7839 KING
    940347       7844 TURNER
    940347       7876 ADAMS

ORA_ROWSCN      EMPNO ENAME
---------- ---------- ----------
    940347       7900 JAMES
    940347       7902 FORD
    940347       7934 MILLER

2.Update table row on scott.emp table
update scott.emp set ename=lower(ename) where empno=7369

3.Check the ora_rowscn again to verify if ora_rowscn change

SQL> select ora_rowscn,empno,ename from scott.emp;

ORA_ROWSCN      EMPNO ENAME
---------- ---------- ----------
  10636202       7369 smith
  10636202       7499 ALLEN
  10636202       7521 WARD
  10636202       7566 JONES
  10636202       7654 MARTIN
  10636202       7698 BLAKE
  10636202       7782 CLARK
  10636202       7788 SCOTT
  10636202       7839 KING
  10636202       7844 TURNER
  10636202       7876 ADAMS

ORA_ROWSCN      EMPNO ENAME
---------- ---------- ----------
  10636202       7900 JAMES
  10636202       7902 FORD
  10636202       7934 MILLER

All the ora_rowscn change from 940347 to 10636202 .Because table scott.emp all record stored in one block .

4.Verify scott.emp table block

select empno,ename ,
dbms_rowid.rowid_relative_fno(rowid)fno,
dbms_rowid.rowid_block_number(rowid) block_no,
dbms_rowid.rowid_row_number(rowid) row_no from scott.emp

     EMPNO ENAME             FNO   BLOCK_NO     ROW_NO
---------- ---------- ---------- ---------- ----------
      7369 smith               4        151          0
      7499 ALLEN               4        151          1
      7521 WARD                4        151          2
      7566 JONES               4        151          3
      7654 MARTIN              4        151          4
      7698 BLAKE               4        151          5
      7782 CLARK               4        151          6
      7788 SCOTT               4        151          7
      7839 KING                4        151          8
      7844 TURNER              4        151          9
      7876 ADAMS               4        151         10

     EMPNO ENAME             FNO   BLOCK_NO     ROW_NO
---------- ---------- ---------- ---------- ----------
      7900 JAMES               4        151         11
      7902 FORD                4        151         12
      7934 MILLER              4        151         13



请使用浏览器的分享功能分享到微信等