Oracle导入和导出exp/imp/expdp/impdp
2017-03-30 16:39
453 查看
导出
exp
将数据库完全导出,用户名system 密码manager 导出到exp_export.dmp中
exp system/manager@hostname:1521/ora11g file=exp_export.dmp full=y log=exp_export.log
将数据库中system用户与sys用户的表导出
exp system/manager@hostname:1521/ora11g file=exp_export.dmp owner=(system,sys) log=exp_export.log
将数据库中的表inner_notify、notify_staff_relat导出
exp aichannel/aichannel@hostname:1521/ora11g file=exp_export.dmp tables=inner_notify,notify_staff_relat log=exp_export.log
将数据库中的表table1中的字段filed1以"00"打头的数据导出
exp system/manager@hostname:1521/ora11g file=exp_export.dmp tables=(table1) query=\" where filed1 like '00%'\" log=exp_export.log
导出密码带有特殊字符的,密码双引号,连接串单引号
exp 'testuser/"test/15/!&/57"@localhost:1521/ora11g' tables=inner_notify file=exp_export.dmp log=exp_export.log
在上面命令后面 加上 compress=y 就可以对导出的文件进行压缩了
其他
Oracle 11G在用EXP导出时,空表不能导出,出现“EXP-00003”错误,再用IMP导入时就会出现“IMP-00003”和“ORA-00942: 表或视图不存在”等错误,这是英文Oracle 11g 新增了一个参数“deferred_segment_creation”,含义是段延迟创建,默认是true。如果这个参数设置为true,你新建了一个表T1,并且没有向其中插入数据,那么这个表不会立即分配extent,也就是不占数据空间,只有当你insert数据后才分配空间。expdp
创建逻辑目录
create directory DUMP_DIR as '/oracle/DUMP_DIR';
在服务器上创建该目录,因为Oracle并不会自动创建,如果目录不存在导出会报错
mkdir -p /oracle/DUMP_DIR
给用户授予在该目睹读取的权限
grant read,write on directory DUMP_DIR to scott;
按用户导
expdp scott/tiger@localhost:1521/ora11g schemas=scott dumpfile=expdp_export.dmp DIRECTORY=DUMP_DIR;
并行进程parallel
expdp scott/tiger@localhost:1521/ora11g directory=DUMP_DIR dumpfile=expdp_export.dmp parallel=40 job_name=expdp40
按表名导
expdp scott/tiger@localhost:1521/ora11g TABLES=emp,dept dumpfile=expdp_export.dmp DIRECTORY=DUMP_DIR;
按查询条件导
expdp scott/tiger@localhost:1521/ora11g directory=DUMP_DIR dumpfile=expdp_export.dmp tables=emp query='WHERE deptno=20';
按表空间导
expdp system/manager DIRECTORY=DUMP_DIR DUMPFILE=expdp_export.dmp TABLESPACES=temp,example;
导整个数据库
expdp system/manager DIRECTORY=DUMP_DIR DUMPFILE=expdp_export.dmp FULL=y;
导入
imp
将exp_export.dmp 中的数据导入 TEST数据库中。
imp system/manager@hostname:1521/ora11g file=exp_export.dmp
上面可能有点问题,因为有的表已经存在,然后它就报错,对该表就不进行导入。
在后面加上 ignore=y 就可以了,但是这样导入的数据可能会出现重复现象
imp system/manager@hostname:1521/ora11g full=y file=exp_export.dmp ignore=y
将exp_export.dmp 中的表table1,table2导入
imp system/manager@hostname:1521/ora11g file=将exp_export.dmp tables=table1,table2
impdp
导到指定用户下
impdp scott/tiger DIRECTORY=DUMP_DIR DUMPFILE=expdp_export.dmp SCHEMAS=scott;
改变表的owner
impdp system/manager DIRECTORY=DUMP_DIR DUMPFILE=expdp_export.dmp TABLES=scott.dept REMAP_SCHEMA=scott:system;
导入表空间
impdp system/manager DIRECTORY=DUMP_DIR DUMPFILE=expdp_export.dmp TABLESPACES=example;
导入数据库
impdb system/manager DIRECTORY=DUMP_DIR DUMPFILE=expdp_export.dmp FULL=y;
追加数据
impdp system/manager DIRECTORY=DUMP_DIR DUMPFILE=expdp_export.dmp SCHEMAS=system TABLE_EXISTS_ACTION=append
使用impdp完成数据库导入时,若表已经存在,有四种的处理方式:
1) skip:默认操作2) replace:先drop表,然后创建表,最后插入数据
3) append:在原来数据的基础上增加数据
4) truncate:先truncate,然后再插入数据
总结
EXP和IMP是客户端工具程序,它们既可以在客户端使用,也可以在服务端使用。EXPDP和IMPDP是服务端的工具程序,他们只能在ORACLE服务端使用,不能在客户端使用。
IMP只适用于EXP导出的文件,不适用于EXPDP导出文件;IMPDP只适用于EXPDP导出的文件,而不适用于EXP导出文件。
EXP不能导出分区表,而EXPDP可以
相关文章推荐
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- Oracle数据导入导出imp/exp命令 适合10g以上expdp/impdp命令
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- [转]10g以上expdp/impdp命令及区别 Oracle数据导入导出imp/exp命令
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- Oracle 导入导出数据 imp/exp impdp/expdp
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- Oracle数据导入导出imp/exp命令(10g以上expdp/impdp命令)
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令 详细的
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令 转自:南水江的鸽子窝
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令
- Oracle数据导入导出imp/exp命令 10g以上expdp/impdp命令