如何判断一个dmp文件是exp还是expdp导出的

今天一个朋友给了一个dmp文件让我导入,没告诉我任何信息。最后还是成功导入了。下面就做个简单测试。


测试导出2分文件 一份是用expdp导出,一份是用exp导出

expdp system/redhat dumpfile=rmantest.dmp directory=orabak tables=rmantest.tt

exp system/redhat file=/orabak/exprman.dmp tables=rmantest.tt

然后用ultraedit编辑工具打开这2个文件

expdp导出的文件头部信息是:

00000000h: 03 01 7C 1D 2C DA 00 67 80 BC 00 00 36 5E 01 E7 ; ..|.,?g€?.6^.?
00000010h: 41 AC 43 7C 7D 07 57 E0 45 00 00 00 00 00 01 00 ; A珻|}.W郋.......
00000020h: 00 00 01 00 00 10 00 03 69 07 DD 09 1A 0B 07 3A ; ........i.?...:
00000030h: 00 00 00 02 02 00 00 00 00 04 00 00 00 00 00 01 ; ................
00000040h: 33 A8 00 22 53 59 53 54 45 4D 22 2E 22 53 59 53 ; 3?"SYSTEM"."SYS
00000050h: 5F 45 58 50 4F 52 54 5F 54 41 42 4C 45 5F 30 31 ; _EXPORT_TABLE_01
00000060h: 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; "...............
00000070h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
00000080h: 00 00 00 00 00 78 38 36 5F 36 34 2F 4C 69 6E 75 ; .....x86_64/Linu
00000090h: 78 20 32 2E 34 2E 78 78 00 00 00 00 00 00 00 00 ; x 2.4.xx........
000000a0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
000000b0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
000000c0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
000000d0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
000000e0h: 00 00 00 00 00 00 00 00 00 00 6F 72 63 6C 00 00 ; ..........orcl..
000000f0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
00000100h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
00000110h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
00000120h: 00 00 00 00 00 00 00 41 4C 33 32 55 54 46 38 00 ; .......AL32UTF8.

exp导出的文件的头部信息是:

00000000h: 03 03 54 45 58 50 4F 52 54 3A 56 31 30 2E 30 32 ; ..TEXPORT:V10.02
00000010h: 2E 30 31 0A 44 53 59 53 54 45 4D 0A 52 54 41 42 ; .01.DSYSTEM.RTAB
00000020h: 4C 45 53 0A 32 30 34 38 0A 30 0A 32 30 0A 30 0A ; LES.2048.0.20.0.
00000030h: 03 54 03 69 03 67 00 01 00 00 00 00 00 00 00 00 ; .T.i.g..........
00000040h: 00 0E 00 20 20 20 20 20 20 20 20 20 20 20 20 20 ; ...             
00000050h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;                 
00000060h: 20 20 20 20 20 D0 C7 C6 DA CB C4 20 39 D4 C2 20 ;      星期四 9月 
00000070h: 32 36 20 31 31 3A 34 35 3A 32 39 20 32 30 31 33 ; 26 11:45:29 2013
00000080h: 63 3A 5C 65 78 70 72 6D 61 6E 2E 64 6D 70 00 00 ; c:\exprman.dmp..
00000090h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
000000a0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
000000b0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
000000c0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................

由上面可以看出 expdp导出的文件里可以看得到实例名和数据库字符集,用户和表空间如果不知道的话可以根据impdp导入的报错日志得知。

而exp导出的文件看不到字符集的信息,但可以用imp导入时候的提示信息得知,如下所示:

[oracle@ora11g ~]$ imp system/redhat file=/orabak/exprman.dmp fromuser=rmantest1 touser=rmantes1t
Import: Release 11.2.0.3.0 - Production on Thu Sep 26 13:55:42 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

Export file created by EXPORT:V11.02.00 via conventional path
import done in US7ASCII character set and UTF8 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
IMP-00034: Warning: FromUser "RMANTEST1" not found in export file
Import terminated successfully with warnings.

而imp-00034这个错误是用户不能在exp导出的文件里找到,可以用UltraEdit工具打开exp导出的文件去查找正确的用户。

所以不管是exp导出的文件,还是expdp导出的文件,字符集和 用户,表空间都能知道了则可以轻松的导入了。


如果别人发给你的dmp文件很大那么用ultraedit打开肯定会很慢可以用linux中的dd命令截取dmp文件的头部信息出来即可

dd if=yourdmpfile.dmp of=newfile.dmp bs=1M count=1

然后打开newfile.dmp文件就可以了。

你可能感兴趣的:(oracle常用)