Data might sometimes get corrupted and when accessing can result in error:
In case data volumes are huge, its difficult to pin point the row which is causing this. Though, there is strategy for doing this.
sql > set autotrace traceonly statistics
sql> execute query (select column from table)
This will show you how many rows are processed before the error occured.
e.g.
22787220 rows selected.
.
Statistics
----------------------------------------------------------
6295 recursive calls
0 db block gets
65041120 consistent gets
10050575 physical reads
0 redo size
4195673524 bytes sent via SQL*Net to client
10634511 bytes received via SQL*Net from client
1519151 SQL*Net roundtrips to/from client
108956 sorts (memory)
0 sorts (disk)
22787220 rows processed
So, you can create an duplicate table and delete these many rows ,i.e., 22787220 records using rownum.
then you again run the query and check how many further records are selected before corrupt data is encountered. This way you can single out the data which is causing issue. Generally this kind of data corruption occurs as a result of DB upgrades.
How to fix:
A simple straight way is to delete the record. but that means loosing information.
Following could be done to resolve this:
update table set column=column||'';
i.e., append empty string to the column and that is it...data corruption is fixed without any loss of it.
similar exercise can be done for number type columns. they generally result in end-of-file on communication channel.
you can check the corruption of it by dumping its canonical form.
sql >select column, dump(column) from table.
---- --------------------------------------------------
1 Typ=2 Len=21: 193,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
actual dump should have been "193,2", no trailing "1"s.
these records also can be updated to get them return to normal canonical form.
update table set column=column + 1 - 1;
Subscribe to:
Post Comments (Atom)
4 comments:
update table set column=column||'';
This is a life saver!
THANK YOU!
thanks .. appending the empty string worked.
Can you please tell how this worked. I am trying to understand that
Regards
Thanks it is useful
excellent fix:
"update table set column=column||'';"
helped me resolve my issue! Thanks a lot for this post!
Post a Comment