从一个用户导出导入到另一个用户

问题

环境:oracle 11g; redhat 6

usera是具有DBA权限,密码为usera

全量导出usera用户下的所有内容,并导入到新建的userb用户

解决

创建Directory: create or replace directory DUMP_DIR_D as '/home/oracle/rhuser/oracledmp';

1、重新测试之前要恢复环境

DROP USER userb cascade;
drop tablespace tbsfsj including contents and datafiles;

2、创建表空间和用户及赋权

create TABLESPACE tbsfsj DATAFILE '/home/oracle/rhuser/tbsfsj.dbf'  -- redhat user
size 10M autoextend on maxsize 30G; create user userb identified by userb default tablespace tbsfsj;
-- grant connect, resource, DATAPUMP_IMP_FULL_DATABASE, DATAPUMP_EXP_FULL_DATABASE
-- to userb;
GRANT dba to userb;
grant read, write on directory DUMP_DIR_D to userb;

3、schemas方式导出

expdp usera/usera directory=DUMP_DIR_D dumpfile=exp1.dmp logfile=exp1.log schemas=usera

4、schemas方式导入

impdp userb/userb schemas=usera directory=DUMP_DIR_D dumpfile=imp1.dmp logfile=imp1.log remap_schema=usera:userb

核对

-- 以新用户userb登录,检查是否成功导入

SQL> select count(*) from user_tables;

  COUNT(*)
----------
126 SQL> select count(*) from user_views; COUNT(*)
----------
1 SQL> select count(*) from user_sequences; COUNT(*)
----------
32 SQL> select count(*) from user_triggers; COUNT(*)
----------
0

脚本

$ ssh root@remote_server_ip

$ su - oracle

$ cd /home/oracle/rhuser
$ cat exp1_schemas_usera.sh
#!/bin/bash
if [ "$1" = '' ]
then
filename=defaultexp
else
filename=$1
fi
dumppathprefix="/home/oracle/rhuser/oracledmp" starttime=`date +'%s'`
expdp usera/usera directory=DUMP_DIR_D dumpfile=$filename.dmp logfile=$filename.log schemas=usera
endtime=`date +'%s'` res="本次运行时间: "$((endtime-starttime))"s"
echo $res>>"$dumppathprefix/$filename.log"
echo $res
$ cat imp1_schemas_usera2fsj.sh
#!/bin/bash
if [ "$1" = '' ]
then
filename=defaultimp
else
filename=$1
fi
if [ "$2" = "" ]
then
dmp=exp1_schemas
else
dmp=$2
fi
dumppathprefix="/home/oracle/rhuser/oracledmp" starttime=`date +'%s'`
impdp userb/userb schemas=usera directory=DUMP_DIR_D dumpfile=$dmp.dmp logfile=$filename.log remap_schema=usera:userb
endtime=`date +'%s'` res="本次运行时间: "$((endtime-starttime))"s"
echo $res>>"$dumppathprefix/$filename.log"
echo $res

讨论

What Is Data Pump Export?

Data Pump Export (hereinafter referred to as Export for ease of reading) is a utility for unloading data and metadata into a set of operating system files called a dump file set. The dump file set can be imported only by the Data Pump Import utility. The dump file set can be imported on the same system or it can be moved to another system and loaded there.

The dump file set is made up of one or more disk files that contain table data, database object metadata, and control information. The files are written in a proprietary, binary format. During an import operation, the Data Pump Import utility uses these files to locate each database object in the dump file set.

Because the dump files are written by the server, rather than by the client, the database administrator (DBA) must create directory objects that define the server locations to which files are written. See "Default Locations for Dump, Log, and SQL Files" for more information about directory objects.

Data Pump Export enables you to specify that a job should move a subset of the data and metadata, as determined by the export mode. This is done using data filters and metadata filters, which are specified through Export parameters. See "Filtering During Export Operations".

To see some examples of the various ways in which you can use Data Pump Export, refer to "Examples of Using Data Pump Export".

Export provides different modes for unloading different portions of the database. The mode is specified on the command line, using the appropriate parameter. The available modes are described in the following sections:

  • "Full Export Mode"
  • "Schema Mode"
  • "Table Mode"
  • "Tablespace Mode"
  • "Transportable Tablespace Mode"

The mode is specified on the command line, using the appropriate parameter. The available modes are described in the following sections:

  • "Full Import Mode"
  • "Schema Mode"
  • "Table Mode"
  • "Tablespace Mode"
  • "Transportable Tablespace Mode"

参考

  1. Oracle简单常用的数据泵导出导入(expdp/impdp)命令举例(上)
  2. Oracle简单常用的数据泵导出导入(expdp/impdp)命令举例(下)

Oracle 11g 数据库 expdp/impdp 全量导入导出的更多相关文章

  1. oracle创建数据库表空间 用户 授权 导入 导出数据库

    windows下可以使用向导一步一步创建数据库,注意编码. windows连接到某一个数据库实例(不然会默认到一个实例下面):set ORACLE_SID=TEST --登录开始创建表空间及可以操作的 ...

  2. Oracle使用par文件进行全库导入导出

    expdp \"/ as sysdba\" PARFILE=/oracle/expdp/AINEWAWARD_20181005.par directory=dumpdir dump ...

  3. Oracle数据迁移expdp/impdp

    Oracle数据迁移expdp/impdp目的:指导项目侧自行进行简单的数据泵迁移工作. 本文实验环境:Oracle 11.2.0.4,利用数据库自带的scott示例用户进行试验测试. 1.首先需要创 ...

  4. ORACLE 数据泵 expdp/impdp

    ORACLE 数据泵 expdp/impdp 一.概念 Oracle Database 10g 引入了最新的数据泵(Data Dump)技术,数据泵导出导入 (EXPDP 和 IMPDP)的作用: 1 ...

  5. hadoop项目实战--ETL--(三)实现mysql表到HIVE表的全量导入与增量导入

    一 在HIVE中创建ETL数据库 ->create database etl; 二 在工程目录下新建MysqlToHive.py 和conf文件夹 在conf文件夹下新建如下文件,最后的工程目录 ...

  6. Sqoop(四)增量导入、全量导入、减量导入

    增量导入 一.说明 当在生产环境中,我们可能会定期从与业务相关的关系型数据库向Hadoop导入数据,导入数仓后进行后续离线分析.这种情况下我们不可能将所有数据重新再导入一遍,所以此时需要数据增量导入. ...

  7. 在Windows 10上安装Oracle 11g数据库出现的问题及解决

    在Windows 10上安装Oracle 11g数据库,并且很多次出现过:当安装的进度条进行到快要结束的时候弹出一个提示框.如下: [Java(TM)2 Platform Standard Editi ...

  8. 完美完全卸载Oracle 11g数据库

    Oracle 11g可在开始菜单中卸载,然后同时需要删除注册表中相关内容. 操作系统:windows10专业版. 卸载步骤: 1.停用oracle服务:进入计算机管理,在服务中,找到oracle开头的 ...

  9. sqoop1.4.6 全量导入与增量导入 与使用技巧

    全量导入: sqoop import --connect jdbc:mysql://192.168.0.144:3306/db_blog --username root --password 1234 ...

随机推荐

  1. tomcat7.x配置APR高并发模式

    Tomcat支持BIO/NIO/APR三种运行模式 ,性能各色春秋! Apr插件提高Tomcat性能 Tomcat可以使用APR来提供超强的可伸缩性和性能,更好地集成本地服务器技术. APR(Apac ...

  2. Java判断对象类型是否为数组

    判断对象是否为数组: public static void main(String[] args) { String[] a = ["1","2"]; if(a ...

  3. AQS的子类在各个同步工具类中的使用情况

    AQS AQS(AbstractQueuedSynchronizer)是 java.util.concurrent的基础.J.U.C中宣传的封装良好的同步工具类Semaphore.CountDownL ...

  4. linux系统编程之管道(二)

    今天继续研究管道,话不多说,言归正传: 对于管道,有一定的读写规则,所以这里主要是对它的规则进行探讨,具体规则如下: 规则一: 下面用程序来验证下,还是用上节学的子进程写数据,父进程读取数据的例子,只 ...

  5. SpringCloud组件相关

    一.前言 原文地址:https://mp.weixin.qq.com/s/mwn2X0G9UgUDz1sgGgL1mA 认识我的朋友可能都知道我这阵子去实习啦,去的公司说是用SpringCloud(但 ...

  6. P1341 无序字母对[欧拉路]

    题目描述 给定n个各不相同的无序字母对(区分大小写,无序即字母对中的两个字母可以位置颠倒).请构造一个有n+1个字母的字符串使得每个字母对都在这个字符串中出现. 解析 毒瘤字符串读入 我就是不喜欢邻接 ...

  7. AngularJs中Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/

    我在使用angularjs的时候报出来这个错误: Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/ 当时 ...

  8. Sharding-JDBC(二)2.0.3版本实践

    目录 一.Sharding-JDBC依赖 二.分片策略 1. 标准分片策略 2. 复合分片策略 3. Inline表达式分片策略 4. 通过Hint而非SQL解析的方式分片的策略 5. 不分片的策略 ...

  9. JDK源码那些事儿之ConcurrentLinkedDeque

    非阻塞队列ConcurrentLinkedQueue我们已经了解过了,既然是Queue,那么是否有其双端队列实现呢?答案是肯定的,今天就继续说一说非阻塞双端队列实现ConcurrentLinkedDe ...

  10. 【Java】Unicode & UTF-8 & UTF-16 & UTF-32

    Unicode Unicode(统一码.万国码.单一码)是计算机科学领域里的一项业界标准,包括字符集.编码方案等.Unicode 是为了解决传统的字符编码方案的局限而产生的,它为每种语言中的每个字符设 ...