天天看点

exp/imp与expdp/impdp的用法区别

1:把用户usera的对象导到用户userb,用法区别在于fromuser=usera touser=userb ,remap_schema='usera':'usera' 。例如

imp system/passwd fromuser=usera touser=userb file=/oracle/exp.dmp log=/oracle/exp.log;

impdp system/passwd directory=expdp dumpfile=expdp.dmp remap_schema='usera':'userb' logfile=/oracle/exp.log;

2:更换表空间,用exp/imp的时候,要想更改表所在的表空间,需要手工去处理一下,

如alter table xxx move tablespace_new之类的操作。

用impdp只要用remap_tablespace='tabspace_old':'tablespace_new'

3:当指定一些表的时候,使用exp/imp 时,tables的用法是 tables=('table1','table2','table3')。

expdp/impdp的用法是tables='table1','table2','table3'

4:

是否要导出数据行

exp (rows=y 导出数据行,rows=n 不导出数据行)

expdp content(all:对象+导出数据行,data_only:只导出对象,metadata_only:只导出数据的记录)

a: exp/imp的使用 (服务器端和客户端都可以执行。并且备份文件可以在客户端产生。)

exp user/password@servicename file=dump.dmp

imp user/password@servicename fromuser=fuser touser=tuser file=dump.dmp

2: expdp/impdp的使用 (服务器端和客户端都可以执行。备份文件只能存在服务器里面。)

i:在使用expdp导出时在oracle需要定义目录变量,在导出的时候需要制定这个变量。如果可以,你可以为每个用户都建立一个单独的备份目录。

sql>create directory dmpdir_user1 as '/home/oracle/backup';

sql>grant read,write on directory dmpdir_user1 to user1;

对了,操作系统内必须创建这个目录。在sql命令行下,并不会产生这个目录的。

[oracle@kook ~]$ mkdir backup

如果你没有制定这个目录的话,默认exp导出存放的目录是$home/rdbms/log里面。至少我的是这样。很奇怪,为什么在这里。

ii:执行导出导入命令

expdp user1/password@servicename schemas=user1 directory=dmpdir_user1 dumpfile=user1.dmp

impdp user2/password@servicename directory=dmpdir_user1 dumpfile=user1.dmp remap_schema=user1:user2 remap_tablespace=user1ts:user2ts

使用expdp/impdp最大的好处可以让我转换表空间。而exp/imp这个是不支持的。处理起来非常麻烦。