Tuesday, June 21, 2011

Oracle exp and imp

Working with exp and imp, I prefer creating configuration files rather than writing everything at the command prompt because I can have a "template" and modify it as needed. Therefore, this is my template for exporting some schemas (not the full database) with data, putting the log file and dump file in /somedir:

BUFFER=1048576
FILE=/somedir/export.dmp
LOG=/somedir/export.log
STATISTICS=NONE
FULL=N
ROWS=Y
OWNER=SOMEUSER,OTHERUSER
DIRECT=Y

The template for exporting a full database is a bit shorter:

BUFFER=1048576
FILE=/somedir/export.dmp
LOG=/somedir/export.log
STATISTICS=NONE
FULL=Y
ROWS=Y
DIRECT=Y

On the other hand, for importing some schemas (from a full or partial export) I use this configuration file:

BUFFER=1048576
FILE=/somedir/export.dmp
LOG=/somedir/export.log
STATISTICS=NONE
FULL=N
ROWS=Y
feedback=10000
commit=n
IGNORE=Y
fromuser=SOMEUSER,OTHERUSER
touser=SOMEUSER,OTHERUSER
CONSTRAINTS=Y
grants=yes

And my template for importing a full database is the following:

BUFFER=1048576
FILE=/somedir/export.dmp
LOG=/somedir/export.log
STATISTICS=NONE
FULL=Y
ROWS=Y
feedback=10000
commit=n
IGNORE=Y

And just to not forget setting the target database name and character settings (very important), I use this little shell script:

#export ORACLE_SID=mydb
#export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1

imp / parfile=/somedir/import.par

Having the more important parameters in your template you can easily change it without checking imp/exp help or documentation, that's why some parameters are included with their default values.

More information:

Import Export FAQ
Checking database character set

No comments:

Post a Comment