您的位置 首页 > 数码极客

expdp如何到指定目录

在使用数据泵前,请先检查数据库字符集是否一致。

1、新建逻辑目录

最好以system等管理员创建逻辑目录,Oracle不会自动创建实际的物理目录“D:\oracleData” (务必手动创建此目录),仅仅是进行定义逻辑路径dump_dir;

sql>conn system/123456a?@orcl as sysdba;

sql>create or replace directory dump_dir as "D:\oracleDumpDir";

2、查看管理员目录(同时查看操作系统是否存在该目录,因为Oracle并不关心该目录是否存在。如果不存在,则报错)

sql>select * from dba_directories;

3、用expdp导出数据

1)导出用户及其对象

expdp scott/tiger@192.168.1.224 schemas=scott dumpfile=ex directory=dump_dir logfile=mylog.log;

expdp scott/tiger@orcl schemas=scott dumpfile=ex directory=dump_dir logfile=mylog.log;

schemas:模式名,与用户名同名

dumpfile:导出的数据文件

directory:目录,即创建的数据泵目录。

2)导出指定表

expdp scott/tiger@orcl tables=emp,dept dumpfile=ex directory=dump_dir;

3)按查询条件导

expdp scott/tiger@orcl directory=dump_dir dumpfile=ex tables=emp query='where deptno=20';

4)按表空间导

expdp jngsswsj/jngsswsj@127.0.0.1:1521/orcl tablespaces=tax directory=dump_dir dumpfile=jng logfile=ex

5)导整个数据库

expdp system/manager@orcl directory=dmp_dir dumpfile= full=y

4、用impdp导入数据

在正式导入数据前,要先确保要导入的用户已存在,如果没有存在,请先新建用户

给用户授权

sql>grant read,write on directory dump_dir to user_name;/*给用户授权数据泵权限*/

sql>grant dba,resource,unlimited tablespace to user_name;

1)导入用户(从用户scott导入到用户scott)

impdp scott/tiger@orcl directory=dump_dir dumpfile=ex schemas=scott;

2)导入表(从scott用户中把表dept和emp导入到system用户中)

impdp system/manager@orcl directory=dump_dir dumpfile=ex tablespace= remap_schema=scott:system;

3)导入表空间

impdp jngsswsj/jngsswsj@127.0.0.1:1521/orcl directory=dump_dir dumpfile=JNGSSWSJ.dmp tablespaces=tax logfile=im;

4)导入数据库

impdp system/manager@orcl directory=dump_dir dumpfile= full=y;

5)追加数据

impdp system/manager@orcl directory=dump_dir dumpfile=ex schemas=systemtable_exists_action

/*****************************************************************************************/

参数介绍

1.USERID:命令行的第一个参数

2.DIRECTORY:转储文件和日志文件存放的目录

3.DUMPFILE:目标转储文件

4.LOGFILE:日志文件

5.FULL:指定全库导出

FULL={Y | N}

6.CONTENT:指定要导出的数据,默认为ALL

CONTENT={ALL|DATA_ONLY|METADATA_ONLY}

ALL:导出对象定义及所有数据

DATA_ONLY:只导出对象数据

METADATA_ONLY:只导出对象定义

例子:

expdp jngsswsj/jngsswsj@127.0.0.1:1521/orcl tablespaces=tax directory=dump_dir dumpfile=jng content=data_only logfile=ex

7.SCHEMAS:指定执行方案模式导出,默认为当前用户模式

8.TABLES:指定表模式导出

9.TABLESPACES:按表空间模式导出

10.PARALLEL:并行,指定执行导出操作的并行进程个数,默认值为1

11.INCLUDE:指定导出时要包含的对象类型及相关对象

INCLUDE = object_type[:name_clause] [,… ]

eg:INCLUDE=TABLE:"IN(SELECT TABLE_NAME FROM CSB_BFB)"

12.EXCLUDE:指定导出执行时要排除的对象类型及相关对象

13.NETWORK_LINK:指定数据库链名,如果要将远程数据库对象导出到本地例程的转储文件中,必须设置该选项

14.TABLE_EXISTS_ACTION={skip|append|truncate|replace}

skip:如果已存在表,则跳过并处理下一个对象;

append:为表增加数据;truncate是截断表,然后为其增加新数据;

replace:删除已存在表,重新建表并追加数据;

ps:文章内容有来自于别人的总结有个人实践总结,仅供学习参考。

责任编辑: 鲁达

1.内容基于多重复合算法人工智能语言模型创作,旨在以深度学习研究为目的传播信息知识,内容观点与本网站无关,反馈举报请
2.仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证;
3.本站属于非营利性站点无毒无广告,请读者放心使用!

“expdp如何到指定目录”边界阅读