`
itspace
  • 浏览: 978979 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

flashback table导致rowid变化

 
阅读更多

首先看测试

SQL>  create table test_move as select * from dba_users;

Table created.

SQL> create user zhoul identified by zhoul;

User created.

SQL> grant dba to zhoul;

Grant succeeded.

SQL> conn zhoul/zhoul
Connected.
SQL>  create table test_move as select * from dba_users; 

Table created.

SQL> select count(*) from test_move;

  COUNT(*)
----------
        28

SQL> select username,rowid from test_move;

USERNAME                       ROWID
------------------------------ ------------------
SYSTEM                         AAAOkdAAEAAAAR8AAA
SYS                            AAAOkdAAEAAAAR8AAB
TEST                           AAAOkdAAEAAAAR8AAC
OEM                            AAAOkdAAEAAAAR8AAD
ZHOUL                          AAAOkdAAEAAAAR8AAE
ZZ                             AAAOkdAAEAAAAR8AAF
SCOTT                          AAAOkdAAEAAAAR8AAG
STRADMIN                       AAAOkdAAEAAAAR8AAH
ASSET                          AAAOkdAAEAAAAR8AAI
MGMT_VIEW                      AAAOkdAAEAAAAR8AAJ
OUTLN                          AAAOkdAAEAAAAR8AAK

USERNAME                       ROWID
------------------------------ ------------------
DBSNMP                         AAAOkdAAEAAAAR8AAL
OLAPSYS                        AAAOkdAAEAAAAR8AAM
SI_INFORMTN_SCHEMA             AAAOkdAAEAAAAR8AAN
ORDPLUGINS                     AAAOkdAAEAAAAR8AAO
XDB                            AAAOkdAAEAAAAR8AAP
ANONYMOUS                      AAAOkdAAEAAAAR8AAQ
CTXSYS                         AAAOkdAAEAAAAR8AAR
WMSYS                          AAAOkdAAEAAAAR8AAS
DMSYS                          AAAOkdAAEAAAAR8AAT
EXFSYS                         AAAOkdAAEAAAAR8AAU
ORDSYS                         AAAOkdAAEAAAAR8AAV

USERNAME                       ROWID
------------------------------ ------------------
MDSYS                          AAAOkdAAEAAAAR8AAW
DIP                            AAAOkdAAEAAAAR8AAX
MDDATA                         AAAOkdAAEAAAAR8AAY
TSMSYS                         AAAOkdAAEAAAAR8AAZ
ORACLE_OCM                     AAAOkdAAEAAAAR8AAa
SYSMAN                         AAAOkdAAEAAAAR8AAb

28 rows selected.

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
1.1000E+13

SQL> select to_char(current_scn) from v$database;

TO_CHAR(CURRENT_SCN)
----------------------------------------
10999711206848

SQL> delete from test_move where username='ZHOUL';

1 row deleted.

SQL> commit;

Commit complete.

SQL> select username,rowid from test_move;

USERNAME                       ROWID
------------------------------ ------------------
SYSTEM                         AAAOkdAAEAAAAR8AAA
SYS                            AAAOkdAAEAAAAR8AAB
TEST                           AAAOkdAAEAAAAR8AAC
OEM                            AAAOkdAAEAAAAR8AAD
ZZ                             AAAOkdAAEAAAAR8AAF
SCOTT                          AAAOkdAAEAAAAR8AAG
STRADMIN                       AAAOkdAAEAAAAR8AAH
ASSET                          AAAOkdAAEAAAAR8AAI
MGMT_VIEW                      AAAOkdAAEAAAAR8AAJ
OUTLN                          AAAOkdAAEAAAAR8AAK
DBSNMP                         AAAOkdAAEAAAAR8AAL

USERNAME                       ROWID
------------------------------ ------------------
OLAPSYS                        AAAOkdAAEAAAAR8AAM
SI_INFORMTN_SCHEMA             AAAOkdAAEAAAAR8AAN
ORDPLUGINS                     AAAOkdAAEAAAAR8AAO
XDB                            AAAOkdAAEAAAAR8AAP
ANONYMOUS                      AAAOkdAAEAAAAR8AAQ
CTXSYS                         AAAOkdAAEAAAAR8AAR
WMSYS                          AAAOkdAAEAAAAR8AAS
DMSYS                          AAAOkdAAEAAAAR8AAT
EXFSYS                         AAAOkdAAEAAAAR8AAU
ORDSYS                         AAAOkdAAEAAAAR8AAV
MDSYS                          AAAOkdAAEAAAAR8AAW

USERNAME                       ROWID
------------------------------ ------------------
DIP                            AAAOkdAAEAAAAR8AAX
MDDATA                         AAAOkdAAEAAAAR8AAY
TSMSYS                         AAAOkdAAEAAAAR8AAZ
ORACLE_OCM                     AAAOkdAAEAAAAR8AAa
SYSMAN                         AAAOkdAAEAAAAR8AAb

27 rows selected.




SQL>  flashback table test_move to scn 10999711206848;
flashback table test_move to scn 10999711206848
                 *
ERROR at line 1:
ORA-08189: cannot flashback the table because row movement is not enabled


SQL> alter table test_move enable row movement;

Table altered.

SQL> alter session set sql_trace=true;

Session altered.


SQL> flashback table test_move to scn 10999711206848;

Flashback complete.

SQL> select username,rowid from test_move;

USERNAME                       ROWID
------------------------------ ------------------
SYSTEM                         AAAOkdAAEAAAAR8AAE
SYS                            AAAOkdAAEAAAAR8AAc
TEST                           AAAOkdAAEAAAAR8AAd
OEM                            AAAOkdAAEAAAAR8AAe
ZHOUL                          AAAOkdAAEAAAAR8AAf
ZZ                             AAAOkdAAEAAAAR8AAg
SCOTT                          AAAOkdAAEAAAAR8AAh
STRADMIN                       AAAOkdAAEAAAAR8AAi
ASSET                          AAAOkdAAEAAAAR8AAj
MGMT_VIEW                      AAAOkdAAEAAAAR8AAk
OUTLN                          AAAOkdAAEAAAAR8AAl

USERNAME                       ROWID
------------------------------ ------------------
DBSNMP                         AAAOkdAAEAAAAR8AAm
OLAPSYS                        AAAOkdAAEAAAAR8AAn
SI_INFORMTN_SCHEMA             AAAOkdAAEAAAAR8AAo
ORDPLUGINS                     AAAOkdAAEAAAAR8AAp
XDB                            AAAOkdAAEAAAAR8AAq
ANONYMOUS                      AAAOkdAAEAAAAR8AAr
CTXSYS                         AAAOkdAAEAAAAR8AAs
WMSYS                          AAAOkdAAEAAAAR8AAt
DMSYS                          AAAOkdAAEAAAAR8AAu
EXFSYS                         AAAOkdAAEAAAAR8AAv
ORDSYS                         AAAOkdAAEAAAAR8AAw

USERNAME                       ROWID
------------------------------ ------------------
MDSYS                          AAAOkdAAEAAAAR8AAx
DIP                            AAAOkdAAEAAAAR8AAy
MDDATA                         AAAOkdAAEAAAAR8AAz
TSMSYS                         AAAOkdAAEAAAAR8AA0
ORACLE_OCM                     AAAOkdAAEAAAAR8AA1
SYSMAN                         AAAOkdAAEAAAAR8AA2

28 rows selected.



SQL> alter session set sql_trace=false;

Session altered.
可以看到rowid已经发生变化,进一步查看后台跟踪文件,发现flashback table其实是做了delete和insert操作。

********************************************************************************

DELETE /*+ BYPASS_UJVC */ FROM (SELECT /*+ ORDERED USE_NL(S) PARALLEL(S,
  DEFAULT) PARALLEL(T, DEFAULT) */ S.rowid FROM SYS_TEMP_FBT T,
  "ZHOUL"."TEST_MOVE" S
WHERE
T.rid = S.rowid and T.action = 'D' and T.object#  = : 1) V


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          5         34          28
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.00       0.00          0          5         34          28

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 67     (recursive depth: 1)

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  DELETE  TEST_MOVE (cr=5 pr=0 pw=0 time=9221 us)
     28   PX COORDINATOR  (cr=5 pr=0 pw=0 time=8462 us)
      0    PX SEND QC (RANDOM) :TQ10000 (cr=0 pr=0 pw=0 time=0 us)
      0     NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us)
      0      PX BLOCK ITERATOR (cr=0 pr=0 pw=0 time=0 us)
      0       TABLE ACCESS FULL SYS_TEMP_FBT (cr=0 pr=0 pw=0 time=0 us)
      0      TABLE ACCESS BY USER ROWID TEST_MOVE (cr=0 pr=0 pw=0 time=0 us)

********************************************************************************

INSERT /*+ PARALLEL(S, DEFAULT) PARALLEL(T, DEFAULT) */ INTO
  "ZHOUL"."TEST_MOVE" SELECT /*+ USE_NL(S) ORDERED PARALLEL(S, DEFAULT)
  PARALLEL(T, DEFAULT) */ S.* FROM SYS_TEMP_FBT T , "ZHOUL"."TEST_MOVE" as of
  SCN :1 S WHERE T.rid = S.rowid and T.action = 'I' and T.object# = :2



call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       1.03          0          5          5          28
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.00       1.03          0          5          5          28

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 67     (recursive depth: 1)

Rows     Row Source Operation
-------  ---------------------------------------------------
     28  PX COORDINATOR  (cr=3 pr=0 pw=0 time=9972 us)
      0   PX SEND QC (RANDOM) :TQ10000 (cr=0 pr=0 pw=0 time=0 us)
      0    NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us)
      0     PX BLOCK ITERATOR (cr=0 pr=0 pw=0 time=0 us)
      0      TABLE ACCESS FULL SYS_TEMP_FBT (cr=0 pr=0 pw=0 time=0 us)
      0     TABLE ACCESS BY USER ROWID TEST_MOVE (cr=0 pr=0 pw=0 time=0 us)

********************************************************************************






分享到:
评论

相关推荐

    oracle flashback特性(闪回语句,闪回表,闪回数据库).doc

    Flashback 特性可以分为三个方面:Flashback Query、Flashback Table 和 Flashback Database。 一、Flashback Query Flashback Query 是 Oracle Flashback 特性中最基本的部分,它允许用户通过闪回查询来查看过去...

    oracle flashback技术总结

    3. **恢复**:使用Flashback Table或Flashback Database根据需求恢复到特定时间点。 ### 结论 Oracle Flashback 技术为数据库管理和恢复提供了强大的工具,尤其是在应对数据丢失或误操作的情况下。通过合理配置和...

    Oracle对于误删误操作的数据进行恢复(flashback query、flashback drop、flashback table、flashback database)

    这些工具包括Flashback Query、Flashback Drop、Flashback Table以及Flashback Database。以下是对这些特性的详细解释: 1. **Flashback Query**: Flashback Query允许用户查询到过去的某个时间点的表中的记录,...

    Oracle 闪回特性 FLASHBACK & RECYCLEBIN

    Flashback Table 的实现是基于 Oracle 的 Flashback Table Log(FTL),该日志记录了表中的所有变化,可以追溯到某个特定的时间点或 SCN。 5. Flashback Drop Flashback Drop 是 Flashback 系列中的一种功能,允许...

    oracle 10g flashback(数据恢复)

    这一操作需要用户具有相应的权限,如 `Flashback any table` 的系统权限或针对特定表的 `Flashback` 权限,以及对该表的 `SELECT`, `INSERT`, `DELETE`, `ALTER` 权限等。 示例代码如下: ```sql SQL> ...

    oracle flashback闪回技术

    最后,Flashback Transaction则可以用来回滚单个事务,这对于恢复特定事务导致的错误非常有用。使用Flashback Transaction Query,可以查看历史事务的详细信息,然后使用ROLLBACK TRANSACTION TO SAVEPOINT或ALTER ...

    flashback——oracle

    首先,`FLASHBACK TABLE`是Oracle Flashback技术的一个关键组件,它用于恢复整个表到先前的状态。当用户意外地删除了表或者对表进行了错误的更新,`FLASHBACK TABLE`命令可以迅速将表恢复到删除或修改前的状态。例如...

    Less17_Flashback_TB3.pdf

    Flashback技术主要包括以下几个方面:Flashback Database、Flashback Table、Flashback Drop以及Flashback Query等。 #### 三、Flashback技术的优势 1. **快速性**:传统的恢复方法通常需要恢复整个数据库或文件,...

    Flashback.doc

    FLASHBACK TABLE employee TO TIMESTAMP TO_TIMESTAMP('2003-04-04 09:30:00', 'YYYY-MM-DD HH24:MI:SS'); ``` 或者通过SCN: ``` FLASHBACK TABLE employee TO SCN 123456; ``` 使用此功能前,可能需要授予用户相应...

    flashback闪回技术

    Flashback技术家族包括了多个成员,如Flashback Database、Flashback Drop、Flashback Query(又细分为Flashback Query、Flashback Version Query、Flashback Transaction Query)和Flashback Table。 #### 二、...

    Row Movement

    在回滚过程中,ROWID 会发生变化,这是因为 Flashback Table 实际上是通过 Flashback Query 将表中数据进行了一次删除、插入操作。 Shrink Segment 是另一个需要打开 ROW MOVEMENT 的功能。Shrink Segment 能帮助...

    Oracle Flashback技术

    2. Flashback Table(闪回表):当需要将整个表恢复到之前的状态时,可以使用闪回表。通过`ALTER TABLE ... FLASHBACK TO TIMESTAMP`或`ALTER TABLE ... FLASHBACK TO SCN`命令,可以快速恢复表到指定的时间戳或系统...

    oracle 闪回 flashback

    Oracle 10g引入了多种闪回功能,包括Flashback Database、Flashback Drop、Flashback Query以及Flashback Table。 1. **Flashback Database**: - Flashback Database允许用户将整个数据库恢复到过去的一个特定...

    Oracle_Flashback_技术_总结.pdf

    在Oracle 10g中,Flashback技术包含了多个组件,如Flashback Database、Flashback Drop、Flashback Query(包括Flashback Query、Flashback Version Query和Flashback Transaction Query)以及Flashback Table。...

    第16章Oracle闪回(Flashback)技术.pptx

    3. 闪回表(Flashback Table) 闪回表可以将表恢复到过去的某个时间点或某个 SCN 值时的状态。该功能允许选择性地复原某些对象,减小恢复时间。 4. 闪回查询(Flashback Query) 闪回查询可以查询过去某个时间点...

    oracle中truncate table后的数据恢复

    Oracle提供了一些闪回工具,如闪回表(Flashback Table)、闪回数据库(Flashback Database)和闪回查询(Flashback Query)。 - 用户具有足够的权限。恢复操作可能需要`SYSDBA`权限。 **2. 使用闪回表恢复数据** ...

    FlashBack Pro 5 Recorder

    《FlashBack Pro 5 Recorder:专业屏幕录制利器详解》 FlashBack Pro 5 Recorder,作为一款备受推崇的屏幕录制工具,以其高效、易用的特性,广泛应用于软件演示、教学指导、在线教程等多个领域。这款软件的核心功能...

    oracle中误删除表后恢复语句(FLASHBACK)

    FLASHBACK TABLE CF_IMPORT_RULE TO BEFORE DROP; FLASHBACK COMPLETE 您可能感兴趣的文章:Oracle误删除表数据后的数据恢复详解Oracle7.X 回滚表空间数据文件误删除处理方法Oracle7.X 回滚表空间数据文件误删除...

Global site tag (gtag.js) - Google Analytics