数据库使用数据泵迁移遇到LOB字段

Posted Mithra

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据库使用数据泵迁移遇到LOB字段相关的知识,希望对你有一定的参考价值。

impdp system/Clic1234 attach=SYS_IMPORT_ILEARN_TRA

desc ILEARN_TRA.NOTIFI_TACTIC

desc ILEARN_TRA.MSG_MAIL
desc ILEARN_TRA.NT_HISTORY
desc ILEARN_TRA.ATTEMPT
desc ILEARN_TRA.NOTIFI_TACTIC
desc ILEARN_TRA.USER_INIT_EXAM

while true
do
ora tsfree
sleep 600
done;


create table t_lob as  select distinct(table_name) from [email protected]_datapump where owner =‘ILEARN_TRA‘;

select distinct(a.table_name) from dba_lobs a,t_lob b where a.table_name not in (select table_name from t_lob) and a.owner=‘ILEARN_TRA‘;

ATTEMPT
USER_INIT_EXAM


select BYTES/1024/1024,b.table_name,a.segment_name from dba_segments a,dba_lobs b where a.segment_name = b.segment_name and b.table_name in (‘ATTEMPT‘,‘USER_INIT_EXAM‘) order by BYTES;

select sum(a.BYTES/1024/1024) as s_size from dba_segments a,dba_lobs b where a.segment_name = b.segment_name and b.owner =‘ILEARN_TRA‘ and b.table_name=‘USER_INIT_EXAM‘;


SUBCATEGORY_PK
select BYTES/1024/1024 from dba_segments where segment_name=‘SUBCATEGORY_PK‘;
select round(count(distinct(CONSTRAINT_NAME))/512*100,2)||‘%‘ as AA from all_constraints where OWNER=‘ILEARN_TRA‘ and CONSTRAINT_TYPE=‘R‘;
select count(distinct(CONSTRAINT_NAME)) from all_constraints where OWNER=‘ILEARN_TRA‘ and CONSTRAINT_TYPE=‘R‘;
select  CONSTRAINT_TYPE  from all_constraints where CONSTRAINT_NAME=‘ILA_ORDER_PART_XREF_ORDER_FK‘;

OWNER                                                                                                             NOT NULL VARCHAR2(30)
CONSTRAINT_NAME                                                                                                   NOT NULL VARCHAR2(30)
CONSTRAINT_TYPE                                                                                                            VARCHAR2(1)
TABLE_NAME  


--create table lob_persent as
insert into lob_persent
SELECT round(sum(c.BYTES / 1024 / 1024) / sum(a.BYTES / 1024 / 1024) * 100, 2) || ‘%‘ AS PERCENT,to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘) as nowTime
FROM [email protected]_datapump a,
    [email protected]_datapump b,
    dba_segments c,
    dba_lobs d
WHERE c.segment_name = d.segment_name
    AND d.OWNER = ‘ILEARN_TRA‘
    AND d.table_name = ‘USER_INIT_EXAM‘
    AND a.segment_name = b.segment_name
    AND b.OWNER = ‘ILEARN_TRA‘
    AND b.table_name = ‘USER_INIT_EXAM‘;
commit;
select * from lob_persent;
   
create or replace procedure test as 
begin 
SELECT round(sum(c.BYTES / 1024 / 1024) / sum(a.BYTES / 1024 / 1024) * 100, 2) || ‘%‘ AS PERCENT,to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘) as nowTime
FROM [email protected]_datapump a,[email protected]_datapump b,dba_segments c,dba_lobs d
WHERE c.segment_name = d.segment_name
AND d.OWNER = ‘ILEARN_TRA‘
AND d.table_name = ‘USER_INIT_EXAM‘
AND a.segment_name = b.segment_name
AND b.OWNER = ‘ILEARN_TRA‘
AND b.table_name = ‘USER_INIT_EXAM‘;
end; 

 

declare 
job1 number;
begin 
dbms_job.submit(job1,‘test;‘,sysdate,‘sysdate+1/144‘);
end; 

select sum(BYTES/1024/1024) from dba_segments a,dba_lobs b where a.segment_name = b.segment_name and b.owner =‘ILEARN_TRA‘;

 


集电港
BYTES/1024/1024 TABLE_NAME           SEGMENT_NAME
--------------- -------------------- ------------------------------
          .0625 ATTEMPT              SYS_LOB0000053178C00039$$
          .0625 ATTEMPT              SYS_LOB0000065763C00039$$
              6 USER_INIT_EXAM       SYS_LOB0000054426C00018$$
             27 USER_INIT_EXAM       SYS_LOB0000067328C00018$$
             45 USER_INIT_EXAM       SYS_LOB0000067328C00028$$
            244 USER_INIT_EXAM       SYS_LOB0000067328C00027$$
            244 USER_INIT_EXAM       SYS_LOB0000067328C00029$$
           7481 USER_INIT_EXAM       SYS_LOB0000054426C00017$$
          67883 USER_INIT_EXAM       SYS_LOB0000067328C00017$$
           
           
卡园
BYTES/1024/1024 TABLE_NAME                     SEGMENT_NAME
--------------- ------------------------------ ---------------------------------------------------------------------------------
          .0625 ATTEMPT                        SYS_LOB0000126246C00039$$
          .0625 ATTEMPT                        SYS_LOB0000128357C00039$$
            .25 USER_INIT_EXAM                 SYS_LOB0000128579C00018$$
          .5625 USER_INIT_EXAM                 SYS_LOB0000126445C00018$$
              2 USER_INIT_EXAM                 SYS_LOB0000128579C00028$$
              8 USER_INIT_EXAM                 SYS_LOB0000128579C00027$$
             80 USER_INIT_EXAM                 SYS_LOB0000128579C00029$$
           6859 USER_INIT_EXAM                 SYS_LOB0000126445C00017$$
          11980 USER_INIT_EXAM                 SYS_LOB0000128579C00017$$
         
         
         
75930
75393.75
   

24732   
         
1分钟256M
         
         
源:         
CREATE  OR  REPLACE  VIEW  USER_INIT_EXAM_LOB 
   (size) 
AS  select sum(a.BYTES/1024/1024) from dba_segments a,dba_lobs b where a.segment_name = b.segment_name and b.owner =‘ILEARN_TRA‘ and b.table_name=‘USER_INIT_EXAM‘;         

 


exec DBMS_STATS.GATHER_schema_STATS (‘ILEARN_TRA‘,estimate_percent => dbms_stats.auto_sample_size,method_opt => ‘for all columns size auto‘,degree => 15,cascade => true);
exec DBMS_STATS.GATHER_schema_STATS (‘ILA_SAP‘,estimate_percent => dbms_stats.auto_sample_size,method_opt => ‘for all columns size auto‘,degree => 15,cascade => true);
exec DBMS_STATS.GATHER_schema_STATS (‘ILEARN_JOB‘,estimate_percent => dbms_stats.auto_sample_size,method_opt => ‘for all columns size auto‘,degree => 15,cascade => true);
exec DBMS_STATS.GATHER_schema_STATS (‘ILEARN‘,estimate_percent => dbms_stats.auto_sample_size,method_opt => ‘for all columns size auto‘,degree => 15,cascade => true);
exec DBMS_STATS.GATHER_schema_STATS (‘ILEARN_BEIYAN‘,estimate_percent => dbms_stats.auto_sample_size,method_opt => ‘for all columns size auto‘,degree => 15,cascade => true);
exec DBMS_STATS.GATHER_schema_STATS (‘APEX_PUBLIC_USER‘,estimate_percent => dbms_stats.auto_sample_size,method_opt => ‘for all columns size auto‘,degree => 15,cascade => true);


ILEARN_TRA     
ILA_SAP        
ILEARN_JOB     
ILEARN         
ILEARN_BEIYAN  
APEX_PUBLIC_USER

 

alter system set "_gc_policy_minimum"=1000000 sid=‘ilndb1‘ scope=both;
alter system set "_gc_affinity_ratio"=1000000 sid=‘ilndb1‘  scope=both;

alter system set "_gc_policy_minimum"=1000000 sid=‘ilndb2‘ scope=both;
alter system set "_gc_affinity_ratio"=1000000 sid=‘ilndb2‘  scope=both;

alter system set "_gc_policy_minimum"=1000000 sid=‘ilndb3‘ scope=both;
alter system set "_gc_affinity_ratio"=1000000 sid=‘ilndb3‘  scope=both;


CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘+DATADG/ILNDB/CONTROLFILE/snapcf_ilndb1.f‘;
CONFIGURE SNAPSHOT CONTROLFILE NAME clear

+DATADG/ILNDB/CONTROLFILE/snapcf_ilndb1.f

以上是关于数据库使用数据泵迁移遇到LOB字段的主要内容,如果未能解决你的问题,请参考以下文章

LOB对象在数据泵导出导入后查询对象数量发现丢失

Data Pump Export 数据泵导出因ORA-31693 ORA-02354 和 ORA-01555 错误且没有LOB损坏而失败 (Doc ID 1507116.1)

使用Oracle数据泵迁移数据库

Oracle使用数据泵 (expdp/impdp)实施迁移

hsqldb休眠持久化@Lob

使用数据泵+dblink迁移数据库,适用于本地空间不足的情况