ITPub博客

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

原创 Oracle 作者:gaopengtttt 时间:2016-09-13 12:26:17 0 删除 编辑
今天无意同事告诉我这样可以查看是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出来的问题件




来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7728585/viewspace-2124879/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
wxh gp_22389860

注册时间:2008-10-13

  • 博文量
    633
  • 访问量
    2778655