EXP/IMP 匯出生產庫表的指定資料到測試庫一例

來源:互聯網
上載者:User

EXP/IMP 匯出生產庫表的指定資料到測試庫一例

一般來講,EXP/IMP是上一代匯出匯入程式,EXPDP/IMPDP是新一代的匯出匯入程式。對於大資料量的匯出匯入首選EXPDP/IMPDP,可以用到並行度,對錶空間等操作上也更加的靈活。對於小資料量的遷移,可以使用exp/imp,操作更簡單。

需求: exp 匯出  A庫(11.2.0.3)zjy使用者的分區表t_jingyu_part部分資料,資料資料表空間 dbs_d_jingyu,索引資料表空間dbs_i_jingyu.

imp 匯入  B庫(11.2.0.4)test使用者下,test使用者的預設資料表空間dbs_d_test。

A庫zjy使用者下準備工作:

create tablespace dbs_d_jingyu datafile '+data' size 100M autoextend off;
create tablespace dbs_i_jingyu datafile '+data' size 20M autoextend off;
create user zjy identified by zjy default tablespace dbs_d_jingyu;

 

create table t_jingyu_part(
id number,
deal_date date,
area_code number,
contents varchar2(4000))
partition by range(deal_date)
(partition p1 values less than(to_date('2014-02-01','YYYY-MM-DD')) tablespace dbs_d_jingyu,
partition p2 values less than(to_date('2014-03-01','YYYY-MM-DD')) tablespace dbs_d_jingyu,
partition p3 values less than(to_date('2014-04-01','YYYY-MM-DD')) tablespace dbs_d_jingyu,
partition p4 values less than(to_date('2014-05-01','YYYY-MM-DD')) tablespace dbs_d_jingyu,
partition p5 values less than(to_date('2014-06-01','YYYY-MM-DD')) tablespace dbs_d_jingyu,
partition p6 values less than(to_date('2014-07-01','YYYY-MM-DD')) tablespace dbs_d_jingyu,
partition p7 values less than(to_date('2014-08-01','YYYY-MM-DD')) tablespace dbs_d_jingyu,
partition p8 values less than(to_date('2014-09-01','YYYY-MM-DD')) tablespace dbs_d_jingyu,
partition p9 values less than(to_date('2014-10-01','YYYY-MM-DD')) tablespace dbs_d_jingyu,
partition p10 values less than(to_date('2014-11-01','YYYY-MM-DD')) tablespace dbs_d_jingyu,
partition p11 values less than(to_date('2014-12-01','YYYY-MM-DD')) tablespace dbs_d_jingyu,
partition p12 values less than(to_date('2015-01-01','YYYY-MM-DD')) tablespace dbs_d_jingyu,
partition p_max values less than(maxvalue) tablespace dbs_d_jingyu );

 

insert into t_jingyu_part(id, deal_date, area_code, contents)
select rownum, to_date(to_char(sysdate-365,'J')+trunc(dbms_random.value(0,365)),'J'), ceil(dbms_random.value(590,599)), rpad('*',400,'*') from dual
connect by rownum <= 100000;
commit;

create index idx_t_jingyu_part_id on t_jingyu_part(id, area_code) local tablespace dbs_i_jingyu;

select count(1) from t_jingyu_part partition(P1);
select count(1) from t_jingyu_part partition(P2);

select count(1) from t_jingyu_part where deal_date >= to_date('2014-11-11','yyyy-mm-dd') and deal_date <= to_date('2014-12-12','yyyy-mm-dd');

exp zjy/zjy parfile=exp.par

file=t_jingyu_part.dmp
log=exp_t_jingyu_part.log
tables=t_jingyu_part
query="where deal_date >= to_date('2014-11-11','yyyy-mm-dd') and deal_date <= to_date('2014-12-12','yyyy-mm-dd')"
statistics=none

在可以使用直接路徑匯出的情景建議使用直接路徑匯出:direct=y 但在本例中不適用。

B庫test使用者:

create tablespace dbs_d_test datafile '+data' size 100M autoextend off;
create user test identified by test default tablespace dbs_d_test;

註:如果按需求,不在B庫建立原表在A庫時對應的資料表空間,就需要先在B庫建立表,指定B庫的資料表空間,比如dbs_d_test;然後再imp匯入,否則必須先建立之前的資料表空間。

imp test/test file=t_jingyu_part.dmp log=imp_t_jingyu_part.log buffer=1024000 ignore=y full=y RESUMABLE=y

----------------------------華麗麗的分割線----------------------------

Oracle匯入匯出expdp IMPDP詳解

Oracle 10g expdp匯出報錯ORA-4031的解決方案

Oracle 10gr2 rac expdp 報錯UDE-00008 ORA-31626

Oracle中利用expdp/impdp備份資料庫的使用說明

Oracle備份還原(expdp/impdp)
 
----------------------------Expdp/Impdp的相關參數----------------------------

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.