Extracting Data from a Corrupt Table using DBMS_REPAIR or Event 10231
9876
Checked for relevance on 17-Dec-1013
***************** *** IMPORTANT *** ***************** This note is an extension to article Note:28814.1 about handling block corruption errors where the block wrapper of a datablock indicates that the block is bad. (Typically for ORA-1578 errors).
The details here will NOT work if only the block internals are corrupt (eg: for ORA-600 or other errors). In this case then from Oracle8i onwards it is possible to use DBMS_REPAIR to mark problem blocks as soft corrupt such that they will then signal ORA-1578 when accessed. See the 10.2 documentation for details of using DBMS_REPAIR.CHECK_OBJECT / FIX_CORRUPT_BLOCKS.
Please read Note:28814.1 before reading this note.
Introduction ~~~~~~~~~~~~ This short article explains how to skip corrupt blocks on an object either using the SKIP_CORRUPT table flag (available from Oracle8i onwards) or the special Oracle event number 10231 which is available in Oracle releases 7 through 8.1 inclusive. The information here explains how to use these options.
Before proceeding you should: a) Be certain that the corrupt block is on a USER table. (ie: not a data dictionary table) b) Have contacted Oracle Support Services and been advised to use event 10231 or the SKIP_CORRUPT flag. c) Have decided how you are to recreate the table. Eg: Export , and disk space is available etc.. d) You have scheduled down-time to attempt the salvage operation OR have restored a copy of the problem database elsewhere in order to perform the data extraction on the "copy". e) Have a backup of the database. f) Have the SQL to rebuild the problem table, its indexes constraints, triggers, grants etc... This SQL should include relevant storage clauses.
What is event 10231 ? ~~~~~~~~~~~~~~~~~~~~~ This event allows Oracle to skip certain types of corrupted blocks on full table scans ONLY hence allowing export or "create table as select" type operations to retrieve rows from the table which are not in the corrupt block. Data in the corrupt block is lost.
The scope of this event is limited for Oracle versions prior to Oracle 7.2 as it only allows you to skip 'soft corrupt' blocks. Most ORA 1578 errors are a result of media corruptions and in such cases event 10231 is useless.
From Oracle 7.2 onwards the event allows you to skip many forms of media corrupt blocks in addition to soft corrupt blocks and so is far more useful. It is still *NOT* guaranteed to work. Note:28814.1 describes alternatives which can be used if this event fails.
What is the SKIP_CORRUPT flag ? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From Oracle8i onwards the functionality of the 10231 event has been externalised on a PER-SEGMENT basis such that it is possible to mark a TABLE to skip over corrupt blocks when possible. The flag is set or cleared using the DBMS_REPAIR package. DBA_TABLES has a SKIP_CORRUPT column which indicates if this flag is set for an object or not.
Setting the event or flag ~~~~~~~~~~~~~~~~~~~~~~~~~ The event can either be set within the session or at database instance level. If you intend to use a CREATE TABLE AS SELECT or ALTER TABLE <> MOVE then setting the event in the session may suffice. If you want to EXPORT the table data then it is best to set the event at instance level, or set the SKIP_CORRUPT table attribute if on Oracle8i (or higher).
Oracle8i,9i,10g,11g ~~~~~~~~~~~~~~~~~~~ Connect as a SYSDBA user and mark the table as needing to skip corrupt blocks thus: execute DBMS_REPAIR.SKIP_CORRUPT_BLOCKS('','');
Now you should be able to issue a CREATE TABLE AS SELECT / ALTER TABLE <> MOVE operation against the corrupt table to extract data from all non-corrupt blocks, or EXPORT the table. Eg: CREATE TABLE salvage_emp AS SELECT * FROM corrupt_emp; or ALTER TABLE <> MOVE
To clear the attribute for a table use: execute DBMS_REPAIR.SKIP_CORRUPT_BLOCKS('','', flags=>dbms_repair.noskip_flag);
Note that when a session skips a corrupt block due to SKIP_CORRUPT being set then a message is written to the trace file (not the alert log) for each block skipped in the form: table scan: segment: file# 6 block# 11 skipping corrupt block file# 6 block# 12
Setting the Event in a Session ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Connect to Oracle as a user with access to the corrupt table and issue the command:
ALTER SESSION SET EVENTS '10231 TRACE NAME CONTEXT FOREVER, LEVEL 10';
Now you should be able to issue a CREATE TABLE AS SELECT operation against the corrupt table to extract data from all non-corrupt blocks, but an export would still fail as the event is only set within your current session. Eg: CREATE TABLE salvage_emp AS SELECT * FROM corrupt_emp;
or
ALTER TABLE <> MOVE
Setting the Event at Instance level ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This requires that the event be added to the init$ORACLE_SID.ora file used to start the instance:
shutdown the database
Edit your init.ora startup configuration file and ADD a line that reads:
event="10231 trace name context forever, level 10"
Make sure this appears next to any other EVENT= lines in the init.ora file.
If you are using an spfile please refer to Note:160178.1 'How to set EVENTS in the SPFILE'.
STARTUP If the instance fails to start check the syntax of the event parameter matches the above exactly. Note the comma as it is important.
SHOW PARAMETER EVENT To check the event has been set in the correct place. You should see the initial portion of text for the line in your init.ora file. If not check which parameter file is being used to start the database.
Select out the data from the table using a full table scan operation. Eg: Use a table level export or create table as select or ALTER TABLE <> MOVE
Export Warning: If the table is very large then some versions of export may not be able to write more than 2Gb of data to the export file. See Note:62427.1 for general information on 2Gb limits in various Oracle releases.
Salvaging data from the corrupt block itself ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SKIP_CORRUPT and event 10231 extract data from good blocks but skip over corrupt blocks. To extract information from the corrupt block there are three main options:
- Select column data from any good indexes This is discussed towards the end of the following 2 articles: Oracle7 - using ROWID range scans Note:34371.1 Oracle8/8i - using ROWID range scans Note:61685.1
- See if Oracle Support can extract any data from HEX dumps of the corrupt block.
- It may be possible to salvage some data using Log Miner
Once you have the data extracted ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Once you have the required data extracted either into an export file or into another table make sure you have a valid database backup before proceeding. The importance of this cannot be over-emphasised.
Double check you have the SQL to rebuild the object and its indexes etc..
Double check that you have any diagnostic information if requested by Oracle support. Once you proceed with dropping the object certain information is destroyed so it is important to capture it now.
Now you can:
If 10231 was set at instance level: Remove the 'event' line from the init.ora file
SHUTDOWN and RESTART the database.
SHOW PARAMETER EVENT Make sure the 10231 event is no longer shown
RENAME or DROP the problem table If you have space it is advisable to RENAME the problem table rather than DROP it at this stage.
Recreate the table. Eg: By importing. Take special care to get the storage clauses correct when recreating the table.
Create any indexes, triggers etc.. required Again take care with storage clauses.
Re-grant any access to the table.
If you RENAMEd the original table you can drop it once the new table has been tested. |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29487349/viewspace-1183910/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Extract rows from a CORRUPT table creating ROWID from DBA_EXTENTS
- How To Replicate Data from Oracle to Postgres Using GoldenGate (Doc ID 1544137.1OracleGo
- ext4 lvreduce報錯superblock or the partition table is likely to be corruptVRBloC
- get_data_from_yml
- Converting Oracle Database from Linux to Windows using RMANOracleDatabaseLinuxWindows
- Step by Step Data Replication Using Oracle GoldenGateOracleGo
- PostgreSQL DBA(181) - Using PostgreSQL as a Data WarehouseSQL
- ORACLE _small_table_threshold與eventOracle
- 【譯】Using .NET for Apache Spark to Analyze Log DataApacheSpark
- [Javascript] Find Items from the end of the JavaScript Array using at, findLast and findLastIndexJavaScriptASTIndex
- SciTech-Mathmatics-ImageProcessing-Remove the Background from an image using Python?REMPython
- OAF export data from VO in xlsx formatExportORM
- NoSuchObjectException(message:ods_db.event table not found)ObjectException
- Connect SQL Server from Linux Client using Windows Authentication and troubleshoot stepsSQLServerLinuxclientWindows
- 【等待事件】SQL*Net more data from dblink事件SQL
- Spark Extracting,transforming,selecting featuresSparkORM
- 關於 mysql 中的 select * from table_a,table_b 的問題MySql
- use azure data studio to create external table for oracleOracle
- You can‘t specify target table ‘Person‘ for update in FROM clause
- 【PTD】DEM generation from laser scanner data using adaptive TIN models利用自適應TIN模型從鐳射掃描器資料生成DEMAPT模型
- [UE] Data Table 對比工具 —— 用於 Data Table 對比以前的資料,檢視有什麼修改
- mysql中You can’t specify target table for update in FROM clMySql
- MySQL主從複製報錯:Got fatal error 1236 from master when reading data fromMySqlGoErrorAST
- 【轉載】使用 BAPI_BUPA_CREATE_FROM_DATA 建立BPAPI
- [20180918]等待事件SQL/Net more data from client.txt事件SQLclient
- [20180925]等待事件SQLNet more data from client 6.txt事件SQLclient
- [20180922]等待事件SQLNet more data from client 4.txt事件SQLclient
- [20180920]等待事件SQLNet more data from client 3.txt事件SQLclient
- [20180926]等待事件SQLNet more data from client 7.txt事件SQLclient
- Could not execute Write_rows event on table time_task.tt_log
- 論文學習筆記 - Classifification of Hyperspectral and LiDAR Data Using Coupled CNNs筆記CNN
- MySQL案例09:Last_IO_Error: Got fatal error 1236 from master when reading data from binary logMySqlASTErrorGo
- scrapy-redis記錄之,重寫make_request_from_data和make_requests_from_urlRedis
- [20201110]How to get the Data Guard broker configuration from a SQL query.txtSQL
- Software-Defined Networking and Security From Theory to Practice (Data-Enabled Engineering).pdf ...
- 閱讀筆記(Communication-Efficient Learning of Deep Networks from Decentralized Data)筆記Zed
- 《Retrieval of oceanic chlorophyll concentration from GOES-R Advanced Baseline Imager using deep learning》論文筆記Go筆記
- Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404HTTP
- ORA-19599 When Backing up an Archivelog that is CorruptHive