大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
今天用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";
成功!