温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

LOB segment corruption

发布时间:2020-08-11 16:21:29 来源:网络 阅读:652 作者:潘麟 栏目:数据库

今天用expdp导数据出现ORA-01555: snapshot too old 错误,表中有clob字段,增加retention time和增加undo表空间都没有用,最后发现是有LOB segment corruption。


ORA-31693: Table data object "NEWCMS"."ARTICLE" failed to load/unload and is being skipped due to error:

ORA-02354: error in exporting/importing data

ORA-01555: snapshot too old: rollback segment number  with name "" too small

ORA-22924: snapshot too old

create table corrupted_data (corrupted_rowid rowid);
 

检查坏块
set concat off
declare
  error_1555 exception;
  pragma exception_init(error_1555,-1555);
  v_lob NCLOB;
  n number;
begin
   for cursor_lob in (select rowid r  from article.html_context) loop
   begin
     select  PT_DESC into v_lob  from   article.html_context  where rowid=cursor_lob.r;
     n:=dbms_lob.instr(v_lob,hextoraw('889911')) ;
   exception
     when error_1555 then
       
insert into corrupted_data values (cursor_lob.r);
       commit;
   end;
  end loop;
end;

PL/SQL procedure successfully completed.


SQL> select * from corrupted_data;


CORRUPTED_ROWID

------------------

AAAS6HAAKAAB++3AAA


发现有一条数据损坏


导出时过滤掉该条记录

expdp newcms/********* schemas=newcms dumpfile=newcms_20160509.dmp query=\"where rowid not in \(\'AAAS6HAAKAAB++3AAA\'\)\" version=10.2.0.4.0

成功导出


在导入时报错

ORA-39083: Object type REF_CONSTRAINT failed to create with error:

ORA-02298: cannot validate (NEWCMS.FK_ARTICLE__REFERENCE_ARTICLE) - parent keys not found

Failing sql is:

ALTER TABLE "NEWCMS"."ARTICLE_TO_COLUMN" ADD CONSTRAINT "FK_ARTICLE__REFERENCE_ARTICLE" FOREIGN KEY ("ARTICLE_CODE") REFERENCES "NEWCMS"."ARTICLE" ("ID") ENABLE

Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

Job "NEWCMS"."SYS_IMPORT_FULL_01" completed with 2 error(s) at 14:45:36


原因:

你要插入的表A里,有外键连接到另一个表B的主键, 你在表A的外键列插入的值 在表B的主键列找不到就不能插入。

解决方法:

如果可以删除主表中的多余记录,保证主表和子表一致

下面的语句根据索引关联信息表生成删除语句


SELECT ' delete from '

 ||a.table_name

 ||' a  where not exists ( select 1 from '

 ||c_pk.table_name

 || ' b  where b.'

 || b.column_name

 ||'=a.'

 ||a.column_name

 ||');'

FROM user_cons_columns a

JOIN user_constraints c

ON a.constraint_name = c.constraint_name

JOIN user_constraints c_pk

ON c.r_constraint_name = c_pk.constraint_name

JOIN user_cons_columns b

ON c_pk.constraint_name = b.constraint_name

WHERE c.constraint_type = 'R'

AND a.table_name        = '&Table_Name'

AND a.constraint_name   ='&FK_NAME';


'DELETEFROM'||A.TABLE_NAME||'AWHERENOTEXISTS(SELECT1FROM'||C_PK.TABLE_NAME||'BWH

--------------------------------------------------------------------------------

 delete from ARTICLE_TO_COLUMN a  where not exists ( select 1 from ARTICLE b  wh

ere b.ID=a.ARTICLE_CODE);

执行该语句

然后执行

alter table "ARTICLE_TO_COLUMN" enable constraint "FK_ARTICLE__REFERENCE_ARTICLE"; 

成功!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI