这个例子来自网络
DECLARE
t1 ku$_dumpfile_info;
v1 NUMBER;
item_meaning VARCHAR2 (40);
v_file_type VARCHAR2 (20);
BEGIN
DBMS_DATAPUMP.GET_DUMPFILE_INFO ('test.dmp',
'DATA_PUMP_DIR',
t1,
v1);
IF v1 = 1
THEN
v_file_type := 'DATA_PUMP_FILE';
ELSE
v_file_type := 'ORIGINAL_EXPORT_FILE';
END IF;
DBMS_OUTPUT.PUT_LINE ('filetype: ' || v_file_type);
FOR i IN 1 .. t1.COUNT
LOOP
item_meaning :=
CASE t1 (i).item_code
WHEN 1 THEN 'FILE_VERSION'
WHEN 2 THEN 'MASTER_PRESENT'
WHEN 3 THEN 'GUID'
WHEN 4 THEN 'FILE_NUMBER'
WHEN 5 THEN 'CHARSET_ID'
WHEN 6 THEN 'CREATION_DATE'
WHEN 7 THEN 'FLAGS'
WHEN 8 THEN 'JOB_NAME'
WHEN 9 THEN 'PLATFORM'
WHEN 10 THEN 'INSTANCE'
WHEN 11 THEN 'LANGUAGE'
WHEN 12 THEN 'BLOCKSIZE'
WHEN 13 THEN 'DIRPATH'
WHEN 14 THEN 'METADATA_COMPRESSED'
WHEN 15 THEN 'DB_VERSION'
WHEN 16 THEN 'MASTER_PIECE_COUNT'
WHEN 17 THEN 'MASTER_PIECE_NUMBER'
WHEN 18 THEN 'DATA_COMPRESSED'
WHEN 19 THEN 'METADATA_ENCRYPTED'
WHEN 20 THEN 'DATA_ENCRYPTED'
ELSE 'UNKNOWN'
END;
DBMS_OUTPUT.PUT_LINE (
RPAD (item_meaning || ':', 30, ' ') || LPAD (t1 (i).VALUE, 30, ' '));
END LOOP;
END;
/
下面是输出结果:
filetype: DATA_PUMP_FILE
FILE_VERSION: 3.1
DB_VERSION: 11.02.00.00.00
MASTER_PRESENT: 1
FLAGS: 2
GUID: 72C6699324794336B115F01D234763
CHARSET_ID: 852
FILE_NUMBER: 1
JOB_NAME: "SYSTEM"."SYS_EXPORT_TABLE_01"
PLATFORM: IBMPC/WIN_NT-8.1.0
INSTANCE: ii1
LANGUAGE: ZHS16GBK
CREATION_DATE: Mon Nov 22 16:41:26 2010
BLOCKSIZE: 4096
METADATA_COMPRESSED: 1
DATA_COMPRESSED: 0
METADATA_ENCRYPTED: 0
DATA_ENCRYPTED: 0
UNKNOWN: 0
UNKNOWN: 2
MASTER_PIECE_COUNT: 1
MASTER_PIECE_NUMBER: 1
PL/SQL 过程已成功完成。
但是这个方法受限于一个活跃的ORACLE实例,如果没有ORACLE实例我只有一个文件怎么看呢?
当然可以用二进制工具打开文件查看。
但是如果文件很大直接打开显然不显示,那么我写了一个小程序非常简单,用GCC编译一下随便就可以了
就是取前1000个字节。
点击(此处)折叠或打开
- /*************************************************************************
- > File Name: test.c
- > Author: gaopeng
- > Mail: gaopp_200217@163.com
- > Created Time: Tue 04 Oct 2016 02:06:17 PM CST
- ************************************************************************/
-
- #include<stdio.h>
- #include <stdlib.h>
-
-
- int main(int argc,char* argv[])
- {
- FILE *fd1;
- FILE *fd2;
-
- char test[1000];
- printf("info:./truc file1 file2\n");
-
- if (argc<3)
- {
- printf("Usage:./truc file1 file2\n");
- exit(3);
- }
-
- if (!(fd1=fopen(argv[1],"r") ) )
- {
- printf("open exp file failed!\n");
- exit(1);
- }
-
- if(!(fd2=fopen(argv[2],"w")))
- {
- printf("open write file failed!\n");
- exit(2);
- }
-
- fread(test,1000,1,fd1);
- fwrite(test,1000,1,fd2);
- printf("endl\n");
- fclose(fd1);
- fclose(fd2);
-
- }
我们来用一下:
gaopeng@bogon:~/testoo$ ./truc userlogin.dmp test.dmp
info:./truc file1 file2
endl
我们查看一下test.dmp文件
hexdump -Cv test.dmp
截取有用的信息
点击(此处)折叠或打开
- 00000000 03 01 f0 ec 55 58 00 67 80 bc 00 01 5c c4 01 3a |....UX.g....\..:|
- 00000010 c9 a8 a6 56 7c 10 14 e0 53 14 ef a8 c0 5b a5 00 |...V|...S....[..|
- 00000020 00 00 01 00 00 10 00 03 54 07 e0 08 18 0b 0d 13 |........T.......|
- 00000030 00 00 00 02 02 00 00 00 00 07 00 00 00 00 00 01 |................|
- 00000040 65 38 00 22 55 47 4c 53 48 22 2e 22 53 59 53 5f |e8."UGLSH"."SYS_|
- 00000050 45 58 50 4f 52 54 5f 54 41 42 4c 45 5f 30 31 22 |EXPORT_TABLE_01"|
- 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000080 00 00 00 00 00 78 38 36 5f 36 34 2f 4c 69 6e 75 |.....x86_64/Linu|
- 00000090 78 20 32 2e 34 2e 78 78 00 00 00 00 00 00 00 00 |x 2.4.xx........|
- 000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 000000b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 000000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 000000e0 00 00 00 00 00 00 00 00 00 00 6c 69 65 62 00 00 |..........lieb..|
- 000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000120 00 00 00 00 00 00 00 5a 48 53 31 36 47 42 4b 00 |.......ZHS16GBK.|
- 00000130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000140 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 |...... .........|
- 00000150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 000001a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 000001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 000001c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 31 31 2e |.............11.|
- 000001e0 30 32 2e 30 30 2e 30 34 2e 30 30 00 00 00 00 00 |02.00.04.00.....|
- 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000210 00 00 00 00 00 00 00 00 00 00 30 30 31 3a 30 30 |..........001:00|
- 00000220 31 3a 30 30 30 30 30 31 3a 30 30 30 30 30 31 00 |1:000001:000001.|
再看看看exp文件
点击(此处)折叠或打开
- 00000000 03 00 01 45 58 50 4f 52 54 3a 56 31 31 2e 30 32 |...EXPORT:V11.02|
- 00000010 2e 30 30 0a 44 50 50 5a 48 55 0a 52 55 53 45 52 |.00.DPPZHU.RUSER|
- 00000020 53 0a 38 31 39 32 0a 30 0a 37 32 0a 30 0a 00 01 |S.8192.0.72.0...|
- 00000030 03 69 07 d0 00 01 00 00 00 00 00 00 00 00 00 09 |.i..............|
- 00000040 00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. |
- 00000050 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
- 00000060 20 20 20 20 20 20 20 20 54 75 65 20 53 65 70 20 | Tue Sep |
- 00000070 31 33 20 32 30 3a 33 31 3a 33 38 20 32 30 31 36 |13 20:31:38 2016|
- 00000080 70 70 7a 68 75 2e 64 6d 70 00 00 00 00 00 00 00 |ppzhu.dmp.......|
- 00000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
明显的不同。郁闷的是没有字符集,不过版本有。这样我们也能判断出事expdp还是exp出来的问题件