oracle数据泵形式导出和导入数据

-------------------------------
drop user test cascade;
drop user visiontv cascade;
drop tablespace test;
drop tablespace visiontv;

-------------------------------
--1. 创建表空间
create tablespace visiontv datafile 'D:\oracle\oradata\oradb01\visiontv.ora' size 100m reuse default storage(initial 500k next 500k pctincrease 20);

--2. 创建用户
create user visiontv identified by visiontv default tablespace visiontv quota 10m on users;

--3. 赋权限
grant connect,resource,dba,sysdba to visiontv;

-------------------------------
--1. 创建表空间
create tablespace test datafile 'D:\oracle\oradata\oradb01\test.ora' size 100m reuse default storage(initial 500k next 500k pctincrease 20);

--2. 创建用户
create user test identified by test default tablespace test quota 10m on users;

--3. 赋权限
grant connect,resource,dba,sysdba to test;

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

1、连接Oracle数据库
C:\> sqlplus / as sysdba

2、创建一个操作目录
SQL> create directory dump_dir as 'd:\oracle\backup\dump';
注意同时需要使用操作系统命令在硬盘上创建这个物理目录。

3、使用以下命令创建一个导出文件目录 hr用户操作dump_dir目录的权限,
SQL> grant read,write on directory dump_dir to visiontv;

4、使用命令expdp导出数据(可以按照用户模式导出、按照表、按照表空间导出和全库导出)
C:\> expdp visiontv/visiontv directory=dump_dir dumpfile=20090517scotttab.dmp schemas=visiontv

5、使用命令impdb导入数据(把visiontv导出的表导入到test表空间中)
C:\> impdp test/test directory=dump_dir dumpfile=20090517scotttab.dmp remap_schema=visiontv:test remap_tablespace=visiontv:test

------------------------------
对Oracle10g中的数据泵导出数据的分析
*******************************************************************************************************************************************
Oracle10g中的数据泵只能用于服务器端,而不能用于客户端,它可以导出表、方案、表空间和整个数据库。
1、导出表
[oracle@rhel4 $expdp scott/tiger directory=dump_dir dumpfile=20080601.dmp tables=dept,emp
2、导出方案
导出方案将方案的所有数据库对象和数据库表导出到一个文件中。
[oracle@rhel4 $ expdp hr/hr directory=dump_dir dumpfile=20080601schema.dmp schemas=hr
3、导出表空间
[oracle@rhel4 u01]$expdp system/sysadmin directory=dump_dir dumpfile=tablespace.dmp tablespaces=users
4、导出整个数据库
[oracle@rhel4 u01]expdp system/sysadmin directory=dump_dir dumpfile=full.dmp full=y


对Oracle10g中的数据泵导入数据的分析
*******************************************************************************************************************************************
1、导入表
[oracle@rhel4 u01]impdp scott/tiger directory=dump_dir dumpfile=dumptab.dmp tables=dept,emp
2、导入方案
一般只能导入自己的方案,如果想导入其他方案,必须具有EXP_FULL_DATABASE或者DBA权限。
[oracle@rhel4 u01]impdp scott/tiger directory=dump_dir dumpfile=dumptab.dmp schemas=scott
3、导入表空间
[oracle@rhel4 u01]impdp system/sysadmin directory=dump_dir dumpfile=tablespace.dmp tablespaces=users
4、导入整个数据库
[oracle@rhel4 u01]impdp system/sysadmin directory=dump_dir dumpfile=full.dmp full=y


expdp scott/tiger directory=expdir   dumpfile=scott_20131008_%U.dmp  parallel=4 version=10.2.0.1 logfile=scott1008.log

impdp trans01/trans01 dumpfile=scott_20131008_01.dmp,scott_20131008_02.dmp directory=expdir remap_schema=scott:trans01  remap_tablespace=users:test  content=all  parallel=4

http://blog.itpub.net/24862808/viewspace-774037/

*******************************************************************************************************************************************

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 跳过对象授权

猜你喜欢

转载自tianlihu.iteye.com/blog/2154395
今日推荐