当前位置: 代码迷 >> 综合 >> exp/imp(expdp/impdp)恢复损坏的数据块
  详细解决方案

exp/imp(expdp/impdp)恢复损坏的数据块

热度:88   发布时间:2024-01-17 09:36:44.0
    除了使用rman的blockrecover命令恢复损坏的数据块外,也可以使用exp/imp(expdp/impdp)命令进行恢复。方法是先用exp命令先导出没有损坏的记录,然后删除表,再使用imp命令导入数据,但是这种恢复方法会丢失记录。如果数据文件中包含索引的数据块有损坏,我们只用简单的删除索引再重建索引即可。下面的例子说明包含表记录的数据块怎么用exp/imp进行不完全恢复。

---创建测试表空间
SYS@orcl>create tablespace test datafile '/u01/app/oracle/oradata/orcl/test01.dbf' size 5m;
Tablespace created.

---创建测试表
SYS@orcl>create table scott.test tablespace test as select * from dba_objects where rownum<=3000;
Table created.

SYS@orcl>select count(*) from scott.test;
  COUNT(*)
----------
      3000

---查出包含行记录的数据块
SYS@orcl>select distinct dbms_rowid.rowid_block_number(rowid) from scott.test order by 1;
DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
------------------------------------
                 131
                 132
                 133
                 134
                 135
                 136
                 137
                 138
                 139
                 140
                 141

DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
------------------------------------
                 142
                 143
                 145
                 146
                 147
                 148
                 149
                 150
                 151
                 152
                 153

DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
------------------------------------
                 154
                 155
                 156
                 157
                 158
                 159
                 161
                 162
                 163
                 164
                 165

DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
------------------------------------