Oracle dump file table data extraction to file (original exp format)

7.7k Views Asked by At

I have Oracle dump files created with original exp (not expdp) (EXPORT:V10.02.01, Oracle 10g). They contain only table data for four tables.

1) I want to extract the table data into files (flat/fixed-width, CVS, or other text file) without importing them into another Oracle DB. [preferred]

2) Alternatively, I need a solution that can import them into an ordinary user (not SYSDBA) so that I can use other tools to extract the data.

My databases are 11g, but I can find 10g databases if needed. I have TOAD for Oracle Xpert 11.6.1.6 as my disposal. I am a moderately experieinced Oracle programmer, but I haven't worked with EXP/IMP before.

(The information below has been obscured to protect the data.)

Here's how the dump files were created:

exp FILE=data.dmp \
LOG=data.log \
TABLES=USER1.TABLE1,USER1.TABLE2,USER1.TABLE3,USER1.TABLE4 \
INDEXES=N TRIGGERS=N CONSTRAINTS=N GRANTS=N

Here's the log:

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
Note: grants on tables/views/sequences/roles will not be exported
Note: indexes on tables will not be exported
Note: constraints on tables will not be exported

About to export specified tables via Conventional Path ...
Current user changed to USER1
. . exporting table                      TABLE1        271 rows exported
. . exporting table                      TABLE2     272088 rows exported
. . exporting table                      TABLE3       2770 rows exported
. . exporting table                      TABLE4      21041 rows exported
Export terminated successfully without warnings.

Thank you in advance.

1

There are 1 best solutions below

4
On

UPDATE: TOAD version 9.7.2 will read a "dmp" file generated by EXP.

Select DATABASE -> EXPORT -> EXPORT FILE BROWSER from the menus.

You need to have the DBA utilities for TOAD installed. There is no real guarantee that the file is parsed correctly, but the data will show up in TOAD in the schema browser.

NOTE: The only other known utility that will a dmp file generated by the exp utility is the imputility. You cannot read the dump file yourself. If you do, you run the risk of parsing the file incorrectly.

If you already have the data in an ORACLE table:

To extract the table data into a file, create a shell script that calls SQL*PLUS and causes SQL*PLUS to spool the table data to a file. You need one script per table.

#!/bin/sh
#NOTE: The path to sqlplus will vary on your system,
#      but it is generally $ORACLE_HOME/bin/sqlplus.
#YOU NEED TO UNCOMMENT THESE LINES AND SET APPROPRIATELY.
#export ORACLE_SID=YOUR_SID
#export ORACLE_HOME=PATH_TO_YOUR_ORACLE_HOME
#export PATH=$PATH:$ORACLE_HOME/bin
sqlplus -s user/pwd@db << EOF
set pagesize 0
set linesize 0
set linesize 255
set heading off
set echo off
SPOOL TABLE1_DATA.txt
REM FOR EACH COLUMN IN TABLE1, SET THE FORMAT
COL FIELD_ID   format 999,999,999
COL FIELD_DATA format a99
select FIELD_ID,FIELD_DATA from TABLE1;
SPOOL OFF
EOF

Make sure you set the line size of each line and set the format of each column. See FIELD_ID above for a number format column and FIELD_DATA for a character column. NOTE: You need to remove the "N rows selected" from the end of the file.

(You can still import the file you created into another schema using the imputility.)