ORACLE关于如何是exp导出还是expdp并查看信息

简介: 今天无意同事告诉我这样可以查看是EXPDP还是EXP文件同时可以查看字符集版本等,是一个不错的办法,但是我想说的不是这个方法向后看 这个例子来自网络 DECLARE    t1             ku$_dumpfile_info; ...
今天无意同事告诉我这样可以查看是EXPDP还是EXP文件同时可以查看字符集版本等,是一个不错的办法,但是我想说的不是这个方法向后看

这个例子来自网络

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个字节。

点击(此处)折叠或打开

  1. /*************************************************************************
  2.     > File Name: test.c
  3.     > Author: gaopeng
  4.     > Mail: gaopp_200217@163.com
  5.     > Created Time: Tue 04 Oct 2016 02:06:17 PM CST
  6.  ************************************************************************/

  7. #include<stdio.h>
  8. #include <stdlib.h>


  9. int main(int argc,char* argv[])
  10. {
  11.         FILE *fd1;
  12.         FILE *fd2;

  13.         char test[1000];
  14.         printf("info:./truc file1 file2\n");

  15.         if (argc<3)
  16.         {
  17.                 printf("Usage:./truc file1 file2\n");
  18.                 exit(3);
  19.         }

  20.         if (!(fd1=fopen(argv[1],"r") ) )
  21.         {
  22.                 printf("open exp file failed!\n");
  23.                 exit(1);
  24.         }

  25.         if(!(fd2=fopen(argv[2],"w")))
  26.         {
  27.                 printf("open write file failed!\n");
  28.                 exit(2);
  29.         }

  30.         fread(test,1000,1,fd1);
  31.         fwrite(test,1000,1,fd2);
  32.         printf("endl\n");
  33.         fclose(fd1);
  34.         fclose(fd2);

  35. }



实际上我就是简单的将原来的dmp文件的前1000字节弄到了另外一个文件,方便打开
我们来用一下:

gaopeng@bogon:~/testoo$ ./truc userlogin.dmp test.dmp
info:./truc file1 file2
endl

我们查看一下test.dmp文件
hexdump -Cv test.dmp

截取有用的信息

点击(此处)折叠或打开

  1. 00000000 03 01 f0 ec 55 58 00 67 80 bc 00 01 5c c4 01 3a |....UX.g....\..:|
  2. 00000010 c9 a8 a6 56 7c 10 14 e0 53 14 ef a8 c0 5b a5 00 |...V|...S....[..|
  3. 00000020 00 00 01 00 00 10 00 03 54 07 e0 08 18 0b 0d 13 |........T.......|
  4. 00000030 00 00 00 02 02 00 00 00 00 07 00 00 00 00 00 01 |................|
  5. 00000040 65 38 00 22 55 47 4c 53 48 22 2e 22 53 59 53 5f |e8."UGLSH"."SYS_|
  6. 00000050 45 58 50 4f 52 54 5f 54 41 42 4c 45 5f 30 31 22 |EXPORT_TABLE_01"|
  7. 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  8. 00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  9. 00000080 00 00 00 00 00 78 38 36 5f 36 34 2f 4c 69 6e 75 |.....x86_64/Linu|
  10. 00000090 78 20 32 2e 34 2e 78 78 00 00 00 00 00 00 00 00 |x 2.4.xx........|
  11. 000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  12. 000000b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  13. 000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  14. 000000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  15. 000000e0 00 00 00 00 00 00 00 00 00 00 6c 69 65 62 00 00 |..........lieb..|
  16. 000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  17. 00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  18. 00000110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  19. 00000120 00 00 00 00 00 00 00 5a 48 53 31 36 47 42 4b 00 |.......ZHS16GBK.|
  20. 00000130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  21. 00000140 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 |...... .........|
  22. 00000150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  23. 00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  24. 00000170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  25. 00000180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  26. 00000190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  27. 000001a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  28. 000001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  29. 000001c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  30. 000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 31 31 2e |.............11.|
  31. 000001e0 30 32 2e 30 30 2e 30 34 2e 30 30 00 00 00 00 00 |02.00.04.00.....|
  32. 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  33. 00000200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
  34. 00000210 00 00 00 00 00 00 00 00 00 00 30 30 31 3a 30 30 |..........001:00|
  35. 00000220 31 3a 30 30 30 30 30 31 3a 30 30 30 30 30 31 00 |1:000001:000001.|
我们看到了很多有用的信息,自己去看吧,这是expdp文件

再看看看exp文件

点击(此处)折叠或打开

  1. 00000000 03 00 01 45 58 50 4f 52 54 3a 56 31 31 2e 30 32 |...EXPORT:V11.02|
  2. 00000010 2e 30 30 0a 44 50 50 5a 48 55 0a 52 55 53 45 52 |.00.DPPZHU.RUSER|
  3. 00000020 53 0a 38 31 39 32 0a 30 0a 37 32 0a 30 0a 00 01 |S.8192.0.72.0...|
  4. 00000030 03 69 07 d0 00 01 00 00 00 00 00 00 00 00 00 09 |.i..............|
  5. 00000040 00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. |
  6. 00000050 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
  7. 00000060 20 20 20 20 20 20 20 20 54 75 65 20 53 65 70 20 | Tue Sep |
  8. 00000070 31 33 20 32 30 3a 33 31 3a 33 38 20 32 30 31 36 |13 20:31:38 2016|
  9. 00000080 70 70 7a 68 75 2e 64 6d 70 00 00 00 00 00 00 00 |ppzhu.dmp.......|
  10. 00000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

明显的不同。郁闷的是没有字符集,不过版本有。这样我们也能判断出事expdp还是exp出来的问题件




相关文章
|
7月前
struts+hibernate+oracle+easyui实现lazyout组件的简单案例——Dept实体类和对应的配置信息
struts+hibernate+oracle+easyui实现lazyout组件的简单案例——Dept实体类和对应的配置信息
|
5月前
|
Oracle 关系型数据库
oracle收集统计信息,游标失效时间
Dbms_stats Invalidates Cursors in Auto_invalidate mode
48 0
|
5月前
|
Oracle 关系型数据库
oracle收集统计信息,游标失效时间
Dbms_stats Invalidates Cursors in Auto_invalidate mode
39 0
|
6月前
|
存储 SQL Oracle
oracle 存储过程导出sql语句 导出为文件
oracle 存储过程导出sql语句 导出为文件
187 0
|
7月前
|
SQL Oracle 关系型数据库
Oracle 数据泵导出导入(映射表空间、Schema)
Oracle 数据泵导出导入(映射表空间、Schema)
|
7月前
|
JavaScript Java 数据库连接
struts+hibernate+oracle+easyui实现lazyout组件的简单案例——Emp实体类和对应的配置信息
struts+hibernate+oracle+easyui实现lazyout组件的简单案例——Emp实体类和对应的配置信息
|
Oracle 关系型数据库 数据库
oracle导入时IMP-00010: 不是有效的导出文件, 头部验证失败
oracle导入时IMP-00010: 不是有效的导出文件, 头部验证失败
236 1
|
7月前
|
SQL Oracle 关系型数据库
Oracle - Spool导出数据到TXT文件
Oracle - Spool导出数据到TXT文件
114 0
|
2月前
|
存储 Oracle 关系型数据库
Oracle数据库的应用场景有哪些?
【10月更文挑战第15天】Oracle数据库的应用场景有哪些?
190 64
|
8天前
|
存储 Oracle 关系型数据库
数据库数据恢复—ORACLE常见故障的数据恢复方案
Oracle数据库常见故障表现: 1、ORACLE数据库无法启动或无法正常工作。 2、ORACLE ASM存储破坏。 3、ORACLE数据文件丢失。 4、ORACLE数据文件部分损坏。 5、ORACLE DUMP文件损坏。
41 11