Tuesday, May 5, 2009

Import / Export full Orcale data

Using 'exp' command:

To export the entire database to a single file dba.dmp in the current directory.
- Login to server
- Use following command:
exp SYSTEM/password FULL=y FILE=dba.dmp LOG=dba.log CONSISTENT=y
or
exp SYSTEM/password PARFILE=params.dat

{oracle.home}/product/10.2.0/bin/expDB/prodDB FULL=Y FILE=forITMc.dmp LOG=export.log CONSISTENT=Y COMPRESS=Y
where params.dat contains the following information:
FILE=dba.dmp
GRANTS=y
FULL=y
ROWS=y
LOG=dba.log

To dump a single schema to disk (we use the scott example schema here)
- Login to server which has an Oracle client
- Use following command:
exp / FIlE=scott.dmp OWNER=scott

To export specific tables to disk.
- Login to server which has an Oracle client
- Use following command:
exp SYSTEM/password FIlE=expdat.dmp TABLES=(scott.emp,hr.countries)
- The above command uses two users : scott and hr

exp / FILE=scott.dmp TABLES=(emp,dept)
the above is only for one user

Using 'imp' command:

To import the full database exported in the example above.
imp SYSTEM/password FULL=y FIlE=dba.dmp

To import just the dept and emp tables from the scott schema
imp SYSTEM/password FIlE=dba.dmp FROMUSER=scott TABLES=(dept,emp)

To import tables and change the owner
imp SYSTEM/password FROMUSER=someUser TOUSER=scott FILE=someUser.dmp TABLES=(unit,manager)

To import just the scott schema exported in the example above
imp / FIlE=scott.dmp

{oracle.home}/product/10.2.0/bin/impDB/pwd4NewDB FILE=forITMc.dmp

No comments: