• 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
  • 相关阅读:
    ThinkPHP整合Kindeditor多图处理示例
    KindEditor用法介绍
    MySQL 1064 错误
    Nginx中虚拟主机与指定访问路径的设置方法讲解
    AJAX PHP无刷新form表单提交的简单实现(推荐)
    教PHP程序员如何找单位(全职+实习),超有用啊!
    利用正则表达式实现手机号码中间4位用星号(*)
    PHP项目做完后想上线怎么办,告诉你免费上线方法!
    备战NOIP——模板复习16
    备战NOIP——STL复习1
  • 原文地址:https://www.cnblogs.com/jyzhao/p/4160146.html
Copyright © 2020-2023  润新知