Example of Exporting Full Database
The
following example shows how to export full database
$exp USERID=scott/tiger FULL=y FILE=myfull.dmp
In the
above command, FILE option specifies the name of the
dump file, FULL option specifies that you want
to export the full database, USERID option specifies the user
account to connect to the database. Note, to perform
full export the user should have DBA or EXP_FULL_DATABASE
privilege.
To
export Objects stored in a particular schemas you can run export utility with
the following arguments
$exp USERID=scott/tiger OWNER=(SCOTT,ALI)
FILE=exp_own.dmp
The
above command will export all the objects stored in SCOTT and ALI’s schema.
To
export individual tables give the following command
$exp USERID=scott/tiger TABLES=(scott.emp,scott.sales) FILE=exp_tab.dmp
This
will export scott’s emp and sales
tables.
If you
include CONSISTENT=Y option in export command
argument then, Export utility will export a consistent image of the table i.e.
the changes which are done to the table during export operation will not be
exported.
Objects
exported by export utility can only be imported by Import utility. Import
utility can run
in Interactive mode or command line mode.
You can
let Import prompt you for parameters by entering the IMP
command followed by your username/password:
Example: IMP SCOTT/TIGER
Or, you can control how Import
runs by entering the IMP command followed
by various arguments. To specify
parameters, you use keywords:
Format: IMP KEYWORD=value or
KEYWORD=(value1,value2,...,valueN)
Example: IMP SCOTT/TIGER IGNORE=Y TABLES=(EMP,DEPT)
FULL=N
or
TABLES=(T1:P1,T1:P2), if T1 is partitioned table
USERID
must be the first parameter on the command line.
Keyword
|
Description
(Default)
|
USERID
|
username/password
|
BUFFER
|
size of data
buffer
|
FILE
|
input files
(EXPDAT.DMP)
|
SHOW
|
just list file
contents (N)
|
IGNORE
|
ignore create
errors (N)
|
GRANTS
|
import grants (Y)
|
INDEXES
|
import indexes
(Y)
|
ROWS
|
import data rows
(Y)
|
LOG
|
log file of
screen output
|
FULL
|
import entire
file (N)
|
FROMUSER
|
list of owner
usernames
|
TOUSER
|
list of usernames
|
TABLES
|
list of table
names
|
RECORDLENGTH
|
length of IO
record
|
INCTYPE
|
incremental
import type
|
COMMIT
|
commit array
insert (N)
|
PARFILE
|
parameter
filename
|
CONSTRAINTS
|
import
constraints (Y)
|
DESTROY
|
overwrite
tablespace data file (N)
|
INDEXFILE
|
write table/index
info to specified file
|
SKIP_UNUSABLE_INDEXES
|
skip maintenance
of unusable indexes (N)
|
FEEDBACK
|
display progress
every x rows(0)
|
TOID_NOVALIDATE
|
skip validation
of specified type ids
|
FILESIZE
|
maximum size of
each dump file
|
STATISTICS
|
import precomputed statistics (always)
|
RESUMABLE
|
suspend when a
space related error is encountered(N)
|
RESUMABLE_NAME
|
text string used
to identify resumable statement
|
RESUMABLE_TIMEOUT
|
wait time for
RESUMABLE
|
COMPILE
|
compile
procedures, packages, and functions (Y)
|
STREAMS_CONFIGURATION
|
import streams
general metadata (Y)
|
STREAMS_INSTANITATION
|
import streams
instantiation metadata (N)
|
To
import individual tables from a full database export dump file give the
following command
$imp scott/tiger FILE=myfullexp.dmp FROMUSER=scott
TABLES=(emp,dept)
This
command will import only emp,
dept tables into Scott user and you
will get a output similar
to as shown below
Export
file created by EXPORT:V10.00.00 via conventional path
import done in
WE8DEC character set and AL16UTF16 NCHAR character set
.
importing SCOTT's objects into SCOTT
.
. importing table "DEPT" 4 rows imported
.
. importing table "EMP" 14 rows imported
Import
terminated successfully without warnings.
For
example, suppose Ali has exported tables into a dump file mytables.dmp.
Now Scott wants to import these tables. To achieve this Scott will give the
following import command
$imp scott/tiger FILE=mytables.dmp FROMUSER=ali TOUSER=scott
Then
import utility will give a warning that tables in the dump
file was exported by user Ali and not you and then proceed.
Suppose you want to import all
tables from a dump file whose name matches a particular pattern. To do so, use
“%” wild
character in TABLES
option. For example, the following command will import all tables whose names
starts with alphabet “e”
and those tables whose name contains alphabet “d”
$imp scott/tiger FILE=myfullexp.dmp FROMUSER=scott
TABLES=(a%,%d%)
The
Export and Import utilities are the only method that Oracle supports for moving
an existing Oracle database from one hardware platform to another. This
includes moving between UNIX and NT systems and also moving between two NT
systems running on different platforms.
The
following steps present a general overview of how to move a database between
platforms.
- As a DBA user, issue the following SQL query to get the exact name of all tablespaces. You will need this information later in the process.
SQL>
SELECT tablespace_name FROM dba_tablespaces;
- As a DBA user, perform a full export from the source database, for example:
>
exp system/manager FULL=y FILE=myfullexp.dmp
- Move the dump file to the target database server. If you use FTP, be sure to copy it in binary format (by entering binary at the FTP prompt) to avoid file corruption.
- Create a database on the target server.
- Before importing the dump file, you must first create your tablespaces, using the information obtained in Step 1. Otherwise, the import will create the corresponding datafiles in the same file structure as at the source database, which may not be compatible with the file structure on the target system.
- As a DBA user, perform a full import with the IGNORE parameter enabled:
>
imp system/manager FULL=y IGNORE=y FILE=myfullexp.dmp
Using IGNORE=y instructs Oracle to
ignore any creation errors during the import and permit the import to complete.
Perform a full backup of
your new database.
No comments:
Post a Comment