Transporting Data Between Database

image

image

The Export utility can provide a logical backup of:

  • Database objects
  • A tablespace
  • An entire database

The Import utility is used to read a valid Export file for moving data into a database. Redo log history cannot be applied to objects that are imported from an export file, therefore data loss may occur, but can be minimized. The DBA can use the Export and Import utilites to complement normal operating system backups by using them to :

  • Create a historical archive of a database object or entire database; for example, when a schema is modified to support changing business requirements.
  • Save table definitions in a binary file. This may be useful for creating and maintaining a baseline of a given schema structure.
  • Move data from one Oracle database version to another, such as upgrading from Oracle8i to Oracle9i.

Export (导出的文件, 只能 Import 这个工具读取)

运行方法:

  • command-line entries
  • Interactive Export prompts (我们系统)
  • Parameter files
  • Oracle Enterprise Manage

另外, 如果你想使用 Export, 你必须具有如下权限:

CREATE SESSION, EXP_FULL_DATABASE

image

command-line 运行模式:

操作系统提示符: exp hr/hr tables = (employees, departments) rows=y file=exp1.dmp   -- 注意, 这里不指定文件路径, 那么就是执行命令的当前目录, 也可以直接指定目录

                    exp hr/hr tables = ( employees, departments) rows=y file = ‘/u01/exp/exp1.dmp’

导出hr 用户的所有object :

    exp system/manager owner=hr directy  -- 如果没有指定file, 那么默认的文件名是 expdat.dmp.

导出 tablespace ts_employees 下的所有 objects, 并同时声称日志文件记录在 ts_employees.log 里

    exp system/manager transport_tablespace=y tablespaces=(ts_employees) log=ts_employees.log

includes all definitions and data modified in the database since the last cumulative or complete export. 

    exp system/manager FULL=y INCTYPE=cumulative FILE=expcum1.dmp

imageimage

image

parameter file:

exp parfile=exp_param.txt

其中 param.txt 为:

  USERID=hr/hr

  TABLES=(employees, departments)

  FILE=exp_one.dmp

  DIRECT=y

image

Import

image

image

image

command-line 运行方式:

imp hr/hr tables=(employees, departments) rows=y file=exp1.dmp  -- 这样会首先创建这两个 table, 然后再进行插入

imp system/manager FROMUSER=hr file=exp2.dmp

imp system/manager transport_tablespace=y TABLESPACES=ts_employees

imageimage

image

image

原文地址:https://www.cnblogs.com/moveofgod/p/3606957.html