几种常见的Oracle备份方法:
The backup methods provided by Oracle can be categorized as follows:
■ Logical backups using Data Pump Export and Import
■ Logical backups using Export (and its companion utility, Import)
■ Physical file system backups: offline backups and online backups
■ Incremental physical file system backups via Recovery Manager (RMAN)
-------------------------------------------------------------------------------
Export and Import
导入和导出都是在DOS环境下进行操作的:
可以使用exp help=y 查看导出的参数信息
同理使用imp help=y 查看导入的参数信息
一共有四种级别的导出:数据库级别(FULL=N为默认参数)、表空间级别、用户级别、表级别
The Export utility has four levels of functionality: Full mode, Tablespace mode, User mode, and
Table mode. You can export partitions via a modified version of Table mode exports.
In Full mode, the full database is exported. The entire data dictionary is read, and the DDL
needed to re-create the full database is written to the export dump file. This file includes creation
commands for all tablespaces, all users, and all of the objects, data, and privileges in their schemas.
In Tablespace mode, all of the objects contained in the specified tablespace(s) will be exported,
including the definition of indexes on the contained objects, even if they are in another tablespace.
In User mode, a user’s objects are exported, as well as the data within them. All grants and
indexes created by the user on the user’s objects are also exported. Grants and indexes created
by users other than the owner are not exported.
In Table mode, a specified table is exported. The table’s structure, indexes, and grants are
exported along with or without its data. Table mode can also export the full set of tables owned
by a user (by specifying the schema owner but no table names). You can also specify partitions
of a table to export.
Export can be run interactively, through Oracle Enterprise Manager, or via command files.
The run-time options that can be specified for Export are listed in Table 46-1, along with their
default values in Oracle Database 10g.
A number of the parameters conflict with each other or may result in inconsistent instructions
for Export. For example, setting full=Y and owner=HR would fail, since the full parameter calls for
a Full export, while the owner parameter specifies a User export.
导出整个库:exp apps/cape file=e:\testexp.dmp log=e:\test.log full=y
(导出文件的格式也可以为dat,日志文件的格式也可以为txt)
导出某个用户下的数据: exp apps/cape file=e:\testexp.dmp log=e:\test.log owner=(workflow,emp)
导入到某个用户:imp apps/cape file=e:\testexp.dmp log=e:\test.log fromuser=workflow touser=testimp
fromuser=emp touser=testemp(多个用户用逗号隔开)
导出整个库的时候,也可以使用:exp apps/cape file=e:\testexp.dmp log=e:\test.log owner=(用户1,用户2,用户3)
代替。
以下是导出过程中需要注意的几个参数:
userid :Username/password of the account running the export. userid must be the first parameter on the command line.
file:Name of the export dump file; default is expdat.dmp.
log:The name of a file to which the log of the export will be written.
row:A Y/N flag to indicate whether rows should be exported. If this is set to N,
then only the DDL for the database objects will be created in the export file.Default is Y.
full:If set to Y, then a Full database export is performed. Default is N.
owner:A list of database accounts to be exported; User exports of those accounts
may then be performed.
tables:A list of tables to be exported; Table exports of those tables may then be
performed. As of Oracle9i, this parameter supports the use of the % and _
wildcards for pattern matching.
四种导入导出的模式只能出现一种
-------
import
The Import utility reads the export dump file and runs the commands stored there. Import may be
used to selectively bring back objects or users from the export dump file.
You can run Import either interactively or via command files.
A number of the Import parameters conflict with each other or may result in inconsistent
instructions for Import. For example, setting full=Y and fromuser=HR would fail, since the full
parameter calls for a Full import, while the fromuser parameter specifies a User import.(模式的限制)
全部导入:imp apps/cape file=e:\testexp.dmp log=e:\test.log full=y
Importing into Different Accounts
To move objects from one user to another user via Export/Import, perform a User export of the
owner of the objects. During the import, specify the owner as the fromuser and the account that
is to own the objects as the touser.
For example, to copy THUMPER’s objects into the FLOWER account, you could execute
the following commands. The first command exports the THUMPER owner, and the second
command imports the THUMPER objects into the FLOWER account.
exp system/manager file=thumper.dat owner=thumper grants=N indexes=Y rows=Y
imp system/manager file=thumper.dat FROMUSER=thumper TOUSER=flower rows=Y indexes=Y
See the Oracle Database Utilities 10 g Release 1 for further details on Export and Import,
along with data recovery examples.
从某个用户导入到另外的用户:imp apps/cape file=e:\testexp.dmp log=e:\test.log fromuser=workflow touser=testimp fromuser=emp touser=testemp(多个用户用逗号隔开)
以下是导入过程中需要注意的几个参数:
userid :Username/password of the account running the export. userid must be the first parameter on the command line.
file:Name of the export dump file; default is expdat.dmp.
log:The name of a file to which the log of the export will be written.
row:A Y/N flag to indicate whether rows should be exported. If this is set to N,
then only the DDL for the database objects will be created in the export file.Default is Y.
full:If set to Y, then a Full database export is performed. Default is N.
owner:A list of database accounts to be exported; User exports of those accounts
may then be performed.
tables:A list of tables to be exported; Table exports of those tables may then be
performed. As of Oracle9i, this parameter supports the use of the % and _
wildcards for pattern matching.
ignore:A Y/N flag to indicate whether the import should ignore errors encountered
when issuing create commands. This flag is used if the objects being importedalready exist. Default is N.
fromuser:A list of database accounts whose objects should be read from the export
dump file (when FULL=N).
touser:A list of database accounts into which objects in the export dump file will be
imported. fromuser and touser do not have to be set to the same value.
compile:A Y/N flag to indicate if procedures, functions, and packages should be
recompiled during import. Default is Y.
--------导入