Thursday, July 29, 2010 22:15

Oracle EXP/IMP FAQs

Posted by ukoom on Tuesday, November 17, 2009, 23:17
This news item was posted in Oracle category and has 0 Comments so far.

Can one import tables to a different tablespace?ITPUB个人空间g!] g4`6k;W)a
Oracle offers no parameter to specify a different tablespace to import data into. Objects will be re-created in the tablespace they were originally exported from. One can alter this behaviour by following one of these procedures:

Pre-create the table(s) in the correct tablespace:

Import the dump file using the INDEXFILE= optionITPUB个人空间 qW4{�B)h q5I
Edit the indexfile. Remove remarks and specify the correct tablespaces.
;W1~%xL0f,H0G0Run this indexfile against your database, this will create the required tables in the appropriate tablespaces
^O/w N!A$V0Import the table(s) with the IGNORE=Y option.
8^8eYcT0Change the default tablespace for the user:

Revoke the “UNLIMITED TABLESPACE” privilege from the userITPUB个人空间 oG�J,fM8bou;fV
Revoke the user’s quota from the tablespace from where the object was exported. This forces the import utility to create tables in the user’s default tablespace.ITPUB个人空间’K,CJ u`’G
Make the tablespace to which you want to import the default tablespace for the user
E3Y6TReVd[0Import the table

Does one need to drop/ truncate objects before importing?ITPUB个人空间'CH7j ]4O~%t
Before one import rows into already populated tables, one needs to truncate or drop these tables to get rid of the old data. If not, the new data will be appended to the existing tables. One must always DROP existing Sequences before re-importing. If the sequences are not dropped, they will generate numbers inconsistent with the rest of the database.

Note: It is also advisable to drop indexes before importing to speed up the import process. Indexes can easily be recreated after the data was successfully imported.

Can one import/export between different versions of Oracle?
h2i#ElR*t;R0Different versions of the import utility is upwards compatible. This means that one can take an export file created from an old export version, and import it using a later version of the import utility. This is quite an effective way of upgrading a database from one release of Oracle to the next.

Oracle also ships some previous catexpX.sql scripts that can be executed as user SYS enabling older imp/exp versions to work (for backwards compatibility). For example, one can run $ORACLE_HOME/rdbms/admin/catexp7.sql on an Oracle 8 database to allow the Oracle 7.3 exp/imp utilities to run against an Oracle 8 database.

Can one export to multiple files?/ Can one beat the Unix 2 Gig limit?ITPUB个人空间/F9M1h@0^ h`
From Oracle8i, the export utility supports multiple output files. This feature enables large exports to be divided into files whose sizes will not exceed any operating system limits (FILESIZE= parameter). When importing from multi-file export you must provide the same filenames in the same sequence in the FILE= parameter. Look at this example:

exp SCOTT/TIGER FILE=D:F1.dmp,E:F2.dmp FILESIZE=10m LOG=scott.logITPUB个人空间e-iR$|-v3@*?~9n
Use the following technique if you use an Oracle version prior to 8i:

Create a compressed export on the fly. Depending on the type of data, you probably can export up to 10 gigabytes to a single file. This example uses gzip. It offers the best compression I know of, but you can also substitute it with zip, compress or whatever.

# create a named pipe
SnY[*{.L&h&{'n0mknod exp.pipe pITPUB个人空间6B7NZv/A b)X"C*u
# read the pipe - output to zip file in the background
U^M[M`-{$h0gzip < exp.pipe > scott.exp.gz &
U;vDa3f-b8f|\ i0# feed the pipeITPUB个人空间![vC:R1cD#E!_
exp userid=scott/tiger file=exp.pipe ...[/code]
Au�ji�?/g1Km0Contributed by Jared Still

Import directly from a compressed export:

# create a  name pipe
9D4DpnK r(mD0mknod imp_pipe pITPUB个人空间sP`sa$Ny&|
# read the zip file and output to pipeITPUB个人空间 xe7{&Dk!j�i2C
gunzip < exp_file.dmp.gz > imp_pipe &ITPUB个人空间/ppJ%bn%s4J
# feed the pipeITPUB个人空间I*FB%FXF7J2[)V
imp
system/pwd@sidfile=imp_pipe log=imp_pipe.log ...ITPUB个人空间3S3N-{R~x
Contributed by Blaise BIBOUE.

How can one improve Import/ Export performance?
Q N/h3rBH!F` J)v|0EXPORT:

Set the BUFFER parameter to a high value (e.g. 2Mb -- entered as an integer "2000000")ITPUB个人空间!n B9zNV
Set the RECORDLENGTH parameter to a high value (e.g. 64Kb -- entered as an integer "64000")ITPUB个人空间,M�OM!vxh_0v
Use DIRECT=yes (direct mode export)
:\;\;GtX&| h {0Stop unnecessary applications to free-up resources for your job.
(_w-Q$]$O$Dl9CL0If you run multiple export sessions, ensure they write to different physical disks.ITPUB个人空间+S5i4C;`_J
DO NOT export to an NFS mounted filesystem. It will take forever.
m6K[5_TB\0IMPORT:

Create an indexfile so that you can create indexes AFTER you have imported data. Do this by setting INDEXFILE to a filename and then import. No data will be imported but a file containing index definitions will be created. You must edit this file afterwards and supply the passwords for the schemas on all CONNECT statements.ITPUB个人空间v6k8o5^YQxS{*p
Place the file to be imported on a separate physical disk from the oracle data filesITPUB个人空间?v(W"ps0ok|
Increase DB_CACHE_SIZE (DB_BLOCK_BUFFERS prior to 9i) considerably in the init$SID.ora file
/t]3K;_a`TF&m0Set the LOG_BUFFER to a big value and restart oracle.
U&t!ev(a2D&PD0Stop redo log archiving if it is running (ALTER DATABASE NOARCHIVELOG;)ITPUB个人空间0` SP’C u(CJ
Create a BIG tablespace with a BIG rollback segment inside. Set all other rollback segments offline (except the SYSTEM rollback segment of course). The rollback segment must be as big as your biggest table (I think?)
e;t#G�P2G!F` w0Use COMMIT=N in the import parameter file if you can afford itITPUB个人空间K,Pw:lV PP`
Use ANALYZE=N in the import parameter file to avoid time consuming ANALYZE statementsITPUB个人空间 v^�_0cY^4Y
Remember to run the indexfile previously created
(J*z[o(g \z0Contributed by Petter Henrik Hansen.

What are the common Import/ Export problems?
TB9t7{”G:PY!cF0ORA-00001: Unique constraint (…) violatedITPUB个人空间nj-{@X k m
You are importing duplicate rows. Use IGNORE=NO to skip tables that already exist (imp will give an error if the object is re-created).ITPUB个人空间3kE.R.Ri-}6r
ORA-01555: Snapshot too old
be”~?-Q Z1a-pa-Sm0Ask your users to STOP working while you are exporting or use parameter CONSISTENT=YES
/_6Q }3Qo0ORA-01562: Failed to extend rollback segmentITPUB个人空间yX’d?4{`
Create bigger rollback segments or set parameter COMMIT=Y while importing
5y”u${/@eBgY!E.bZ0IMP-00015: Statement failed … object already exists…
l!n#s N0Gc0Use the IGNORE=Y import parameter to ignore these errors, but be careful as you might end up with duplicate rows.

Reference:

http://www.orafaq.com/wiki/Import_Export_FAQ

Related Posts

Leave a Reply

You can leave a response, or trackback from your own site.