Professional Documents
Culture Documents
Instructor's Notes
(If applicable)
This hands-on lesson will teach you how to use the import and export utilities to
perform logical backups of the database.
Other Text:
(Examples or comments displayed on slide, if any).
SkillBuilders Advertisement
Instructor's Notes
(If applicable)
Logical backups are taken with the Export utility. They are called "logical"
backups, because logical database objects such as a table are backed up. Export
writes output to a binary file, which can be read by the Import utility.
The export utility is most often used to create secondary backups (what if your
RMAN backup sets are lost?) and to move database objects by FTP'ing to
another server and importing.
Other Text:
(Examples or comments displayed on slide, if any).
Physical backups backup datafiles. Use RMAN for this
SkillBuilders Advertisement
Instructor's Notes
(If applicable)
The Export utility creates a binary dump file containing the object definitions
(DDL) and data (if ROWS=Y parameter used, otherwise the file contains just
the DDL). The file is in an Oracle proprietary format; the Import utility must be
used to restore the file.
The Export utility is used when the database is open. However, consistency
must be considered if more than one related object is being exported. Export
does not, by default, maintain consistency across tables. So, you will need to
either STARTUP RESTRICT or use the Export CONSISTENT=Y parameter.
However the latter solution may require very large rollback or undo segments
making this a difficult solution.
EXPORT (and IMPORT) can be run from the operating system command line,
from command files (scripts) and from Oracle Enterprise Manager (OEM).
Other Text:
(Examples or comments displayed on slide, if any).
SkillBuilders Advertisement
Instructor's Notes
(If applicable)
The Export utility supports several modes. In each mode, we can request that
just the DDL to recreate the object be exported or, perhaps more commonly,
request that the DDL and the contents of the tables be exported.
Instructor's Notes
(If applicable)
EXPORT can be invoked from the OS command line from the server or any
client that has had client administrator installation performed on it. (The OS
command is "EXP".)
In this example (not all output shown), the following options are used:
o USERID= (The string USERID= can be omitted if the first option
passed is the username/password) Specify the username to connect to
the database and run the export. The user requires the
EXP_FULL_DATABASE role to export objects other than their own.
o OWNER= - This denotes a user-level export. Specify the user or a
comma delimited list of users whose objects should be exported.
Other Text:
(Examples or comments displayed on slide, if any).
C:\>exp system/dave@angela owner=dave compress=n file=c:\backup\dave.dmp
consistent=y log=c:\backup\dave.log
Export: Release 9.2.0.1.0 - Production on Mon Jun 9 10:21:15 2003
Connected to: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
About to export DAVE's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export DAVE's tables via Conventional Path ...
. . exporting table ALL_MY_DDL 2 rows exported
. . exporting table BLOB_TABLE 0 rows exported
. . exporting table CUST 0 rows exported
. . exporting table CUSTOMER 14 rows exported
Output messages
SkillBuilders Advertisement
Instructor's Notes
(If applicable)
o FILE= - Specify the path and file name of the output dump file (I.e. the
file that contains the exported data). The default is "EXPDAT.DMP" in
the current working directory.
o CONSISTENT= - "Y" requests a read-consistent version of all objects.
This should be used if more than one related object is being exported
and the objects are available for update. Can require very large rollback
or undo segments making this a difficult solution. Consider STARTUP
RESTRICT to prevent access by other users instead of this option.
o LOG= - The path and name of a file where a log of the export process
will be written. The message we hope for, I.e. the message that indicates
all is well can be found at the end of the log file: "Export terminated
successfully without warnings."
Other Text:
(Examples or comments displayed on slide, if any).
SkillBuilders Advertisement
Instructor's Notes
(If applicable)
Note that the flashback export does not support objects that have been dropped,
altered or truncated.
Other Text:
(Examples or comments displayed on slide, if any).
C:\>exp parfile=c:\backup\dave.par
[oracle@Dev]$ exp system/dave file=fulldb full=y consistent=y
C:\>exp system/dave@angela owner=dave file=c:\backup\dave.dmp consistent=y
log=c:\backup\dave.log flashback_scn=13211585
C:\>exp system/dave@angela . . .
flashback_time='"2003-06-09 11:00:00"'
SkillBuilders Advertisement
Instructor's Notes
(If applicable)
Other Text:
(Examples or comments displayed on slide, if any).
C:\>exp system/dave@angela tablespaces=users consistent=y
C:\>exp system/dave@angela tables=dave.t%
C:\>exp system/dave@angela tables=dave.t2
query=\"where status='VALID'\"
C:\>exp system/dave@angela full=y file=c:\backup\dave.dmp consistent=y direct=y
SkillBuilders Advertisement
Instructor's Notes
(If applicable)
The import utility is used to read the exported dump file. Import will create the
objects defined in the file and, if ROWS=Y is used, insert rows of data into the
objects.
The entire contents of the dump file do not need to be imported. Use the
FROMUSER parameter to specify which users objects you want to import.
You'll need CREATE SESSION privilege and all the system privileges required
to create the objects found in the dump file. If the dump file was created with a
full export, you will require the IMP_FULL_DATABASE role. (This role, by
default, is granted to the DBA role.)
It is common to use FTP to send the dump file to another server. Remember the
dump file is in binary format; therefore, use binary mode FTP so the dump file
is not corrupted.
SkillBuilders Advertisement
Instructor's Notes
(If applicable)
The first example is a FULL import. It will create all the objects found in the
dump file and insert any data found in the dump file.
The second example is a user-mode import. Even if the dump file contains a full
dump, it will import only those objects owned by user DAVE.
The third and final example is another user-mode import. However, this
example creates all objects exported from the DAVE schema in the DAVETEST
schema. User DAVETEST must exist and the user needs quota on the
appropriate tablespace(s) prior to running this import.
Other Text:
(Examples or comments displayed on slide, if any).
C:\>imp system/dave@angela file=c:\backup\dave.dmp full=y
C:\>imp system/dave@angela file=c:\backup\dave.dmp fromuser=dave
C:\>imp system/dave@angela file=c:\backup\dave.dmp fromuser=dave touser=davetest
SkillBuilders Advertisement
Instructor's Notes
(If applicable)
o Sometimes you will import just for the data the objects may already
exists. In this case, use the IGNORE=Y option to tell import to continue
even if there are errors.
o By default, import commits after each object. This may require too much
undo segment space. Use the COMMIT=Y parameter to tell import to
commit more frequently after each array. The default array size is
operating system dependent but can be overridden with the BUFFER
parameter.
o If you are importing tablespaces into a second database on the same
server you exported from, care must be taken to not overwrite the
datafiles from the source database. Use the DESTROY=N parameter to
prevent import from corrupting existing datafiles. It does this by not
including the REUSE option on the CREATE TABLESPACE statement.
In this situation, pre-create the tablespaces needed on the 2nd instance,
of course using different datafile names.
Other Text:
(Examples or comments displayed on slide, if any).
SkillBuilders Advertisement
Instructor's Notes
(If applicable)
o The SHOW=Y parameter simply displays the contents of the dump file,
without importing.
o In some situations, you may want Oracle to recalculate statistics rather
than importing them from the dump file. Use
STATISTICS=RECALCULATE to do this. By default, existing statistics
are imported.
o As of Oracle9i, Import supports resumable space management feature.
Resumable Space Management (RSM) manages space allocation
failures. It allows the transaction that has encountered the space
allocation error to suspend. If you fix the cause of the error, the
transaction will automatically resume. If you do not fix the error, you
will eventually get a RSM time out error. See the RESUMABLE%
parameters.
Other Text:
(Examples or comments displayed on slide, if any).
SkillBuilders Advertisement
Instructor's Notes
(If applicable)
Other Text:
(Examples or comments displayed on slide, if any).
SkillBuilders Advertisement
Instructor's Notes
(If applicable)
1. Produce a list of tables owned by the administrative user created for this
course.
2. Execute a consistent user-mode export on this user.
3. Drop this user.
4. Take the necessary actions to recreate the user and all tables.
Other Text:
(Examples or comments displayed on slide, if any).