• oracle导出表的办法


    1.先进行表分析(一定要执行此步,否则查询空表可能不准确)

    select 'analyze table '||table_name||' compute statistics;' from user_tables;

    2.再查询哪些表是空的(此步可以省略,直接进行第三步)

    select table_name from user_tables where NUM_ROWS=0 order by table_name;

    3.最后生成alert语句
    select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0 order by table_name;

    4.导出表---通过PLSQL Developer(tools->Export Tables)导出。

    5.导入时通过命令行(cmd)进行导入 imp user/pass@orcl file=E:datadata.dmp full=y

    6.导出序列和视图 ---通过PLSQL Developer(tools->Export User Objects,然后选择要导出的视图)导出。

    7.导入序列和视图---将seq.sql和view.sql中的空间名替换掉,然后新建Command Window-->分别load两个文件导入执行即可。

    *********************************另外一种导出方法*********************************

    EXP和IMP是客户端工具程序,它们既可以在客户端使用,也可以在服务端使用。

    EXPDP和IMPDP是服务端的工具程序,他们只能在ORACLE服务端使用,不能在客户端使用。

    如果想导入的用户已经存在:
    1. 导出用户 expdp user1/pass1 directory=dumpdir dumpfile=user1.dmp
    2. 导入用户 impdp user2/pass2 directory=dumpdir dumpfile=user1.dmp REMAP_SCHEMA=user1:user2 EXCLUDE=USER

    如果想导入的用户不存在:
    1. 导出用户 expdp user1/pass1 directory=dumpdir dumpfile=user1.dmp
    2. 导入用户 impdp system/passsystem directory=dumpdir dumpfile=user1.dmp REMAP_SCHEMA=user1:user2
    3. user2会自动建立,其权限和使用的表空间与user1相同,但此时用user2无法登录,必须修改user2的密码

    今天需要另一个数据库的用户表导入到当前库中,但用户名不相同,以前exp/imp时,可以指定fromuser和touser来解决,在expdp中也提供了类似的解决方法

    impdp system/zlsoft dumpfile=expdp:EXPDP_ZLHIS.DMP nologfile=y tables=zlhis.dept remap_schema=zlhis:scott remap_tablespace=ZL9BASEITEM:users,zl9indexhis
    :users,zl9indexmtl:users table_exists_action=truncate exclude=object_grant

    几个重要参数的说明一下:

    1、remap_user 重新映射用户,格式: source_user1:target_user1,source_user2:target_user2

    2、remap_tablespace 重新映射表空间

    3、 table_exists_action 表已经存在的动作 有效关键字: (SKIP), APPEND, REPLACE 和 TRUNCATE。

    4、exclude=object_grant 跳过对象授权

    ****************第三种导出方法(常用)****************

    exp scott/tiger@orcl file=D:database.dmp

    imp scott/tiger@orcl full=y file=D:database.dmp

    非本机:

    imp user1/pass1@192.168.153.68:1521/orcl file=E:data.dmp full=y

    exp user1/pass1@192.168.153.68:1521/orcl file=E:data.dmp full=y

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

    从一个用户导到另外一个用户

    exp 'user1/user1@orcl' file=D:dataxxx.dmp owner=user1

    imp 'user2/user2@orcl' file=D:dataxxx.dmp fromuser=user1 touser=user2 ignore=y constraints=y grants=y

    参看:https://blog.csdn.net/mzd8341/article/details/76595772

     这样导出的表可能不全,请先看文章开头如何执行 alter table table_name_xxx allocate extent;

    *********************************导出部分表方法*********************************

    exp scott/tiger@orcl  file=d: est.dmp statistics=none TABLES=(TABLE1,TABLE2,TABLE3)

    参看:https://blog.csdn.net/u011277123/article/details/53665302

  • 相关阅读:
    SpringCloud------熔断与降级
    Linux中的defunct进程(僵尸进程)
    网站论坛收藏
    同步与阻塞,异步与非阻塞的区别
    Linux下批量杀掉筛选进程
    MapReduce运行原理和过程
    TF-IDF原理
    如何解决VMware 虚拟机不能铺满屏幕
    桥接和nat连接
    http: server gave HTTP response to HTTPS client & Get https://192.168.2.119/v2/: dial tcp 192.168.2.119:443: getsockopt: connection refused
  • 原文地址:https://www.cnblogs.com/nsw2018/p/7216915.html
Copyright © 2020-2023  润新知