How to determine the Schemas inside an Oracle Data Pump Export file

后端 未结 8 427
梦谈多话
梦谈多话 2021-01-30 13:28
  • I have an Oracle database backup file (.dmp) that was created with expdp.
  • The .dmp file was an export of an entire database.
  • I need to resto
相关标签:
8条回答
  • 2021-01-30 13:41

    The running the impdp command to produce an sqlfile, you will need to run it as a user which has the DATAPUMP_IMP_FULL_DATABASE role.

    Or... run it as a low privileged user and use the MASTER_ONLY=YES option, then inspect the master table. e.g.

    select value_t 
    from SYS_IMPORT_TABLE_01 
    where name = 'CLIENT_COMMAND' 
    and process_order = -59;
    
    col object_name for a30
    col processing_status head STATUS for a6
    col processing_state head STATE for a5
    select distinct
      object_schema,
      object_name,
      object_type,
      object_tablespace,
      process_order,
      duplicate,
      processing_status,
      processing_state
    from sys_import_table_01
    where process_order > 0
    and object_name is not null
    order by object_schema, object_name
    /
    

    http://download.oracle.com/otndocs/products/database/enterprise_edition/utilities/pdf/oow2011_dp_mastering.pdf

    0 讨论(0)
  • 2021-01-30 13:47

    My solution (similar to KyleLanser's answer) (on a Unix box):

    strings dumpfile.dmp | grep SCHEMA_LIST
    
    0 讨论(0)
  • 2021-01-30 13:50

    Update (2008-09-19 10:05) - Solution:

    My Solution: Social engineering, I dug real hard and found someone who knew the schema name.
    Technical Solution: Searching the .dmp file did yield the schema name.
    Once I knew the schema name, I searched the dump file and learned where to find it.

    Places the Schemas name were seen, in the .dmp file:

    • <OWNER_NAME>SOURCE_SCHEMA</OWNER_NAME> This was seen before each table name/definition.

    • SCHEMA_LIST 'SOURCE_SCHEMA' This was seen near the end of the .dmp.

    Interestingly enough, around the SCHEMA_LIST 'SOURCE_SCHEMA' section, it also had the command line used to create the dump, directories used, par files used, windows version it was run on, and export session settings (language, date formats).

    So, problem solved :)

    0 讨论(0)
  • 2021-01-30 13:53

    Step 1: Here is one simple example. You have to create a SQL file from the dump file using SQLFILE option.

    Step 2: Grep for CREATE USER in the generated SQL file (here tables.sql)

    Example here:

    $ impdp directory=exp_dir dumpfile=exp_user1_all_tab.dmp  logfile=imp_exp_user1_tab sqlfile=tables.sql
    

    Import: Release 11.2.0.3.0 - Production on Fri Apr 26 08:29:06 2013

    Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

    Username: / as sysdba

    Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA Job "SYS"."SYS_SQL_FILE_FULL_01" successfully completed at 08:29:12

    $ grep "CREATE USER" tables.sql
    

    CREATE USER "USER1" IDENTIFIED BY VALUES 'S:270D559F9B97C05EA50F78507CD6EAC6AD63969E5E;BBE7786A5F9103'

    Lot of datapump options explained here http://www.acehints.com/p/site-map.html

    0 讨论(0)
  • 2021-01-30 13:56

    You need to search for OWNER_NAME.

    cat -v dumpfile.dmp | grep -o '<OWNER_NAME>.*</OWNER_NAME>' | uniq -u
    

    cat -v turn the dumpfile into visible text.

    grep -o shows only the match so we don't see really long lines

    uniq -u removes duplicate lines so you see less output.

    This works pretty well, even on large dump files, and could be tweaked for usage in a script.

    0 讨论(0)
  • 2021-01-30 13:58

    impdp exports the DDL of a dmp backup to a file if you use the SQLFILE parameter. For example, put this into a text file

    impdp '/ as sysdba' dumpfile=<your .dmp file> logfile=import_log.txt sqlfile=ddl_dump.txt
    

    Then check ddl_dump.txt for the tablespaces, users, and schemas in the backup.

    According to the documentation, this does not actually modify the database:

    The SQL is not actually executed, and the target system remains unchanged.

    0 讨论(0)
提交回复
热议问题