Expdp,impdp工具的使用

  1. 需要创建DIRECTORY

    expdp,impdp是新的数据导出,导入工具,是基于server端的工具,所有的文件需要在服务器端存放,这是有别与旧的导出/导入工具(exp,imp).

    创建的语句: create or replace directory dmp_dir as '/dmp';

    给用户赋权: grant read,write on dmp_dir to user1,user2;

[@more@]
  1. 我们可以为数据文件和日志文件创建不同的directory
  2. create ora replace directory dmp_log as '/dmplog/';
  3. 导出数据时,将数据文件与日志文件存放到不同的地方
  4. expdp user1/***** directory=dmp_dir dumpfile=user1.dmp logfile=dmp_log:user1.log
  5. SQL>SELECT directory_name, directory_path FROM dba_directories ;
  6. 查询目前已经定义的DIRECTORY.
  7. 导出,导入的文件集合的名称可以自动生成,使用%U

    expdp user1/**** directory=dmp_dir dumpfile=user1_%U.dmp filesize=2g logfile=user1.log

    这样可以自动从01开始编号,避免了旧工具导出时文件名称重复的问题.

    1. 新旧导出工具的操作有所不同,下面摘录了具体的解释,来自与ORACLE的官方文档.
    2. Table 3-2 Original Import Parameters and Their Counterparts in Data Pump Import
    1. Original Import Parameter

    Comparable Data Pump Import Parameter

    BUFFER

    A parameter comparable to BUFFER is not needed.

    CHARSET

    A parameter comparable to CHARSET is not needed.

    COMMIT

    A parameter comparable to COMMIT is not supported.

    COMPILE

    A parameter comparable to COMPILE is not supported.

    CONSTRAINTS

    EXCLUDE=CONSTRAINT

    DATAFILES

    TRANSPORT_DATAFILES

    DESTROY

    REUSE_DATAFILES

    FEEDBACK

    STATUS

    FILE

    DUMPFILE

    FILESIZE

    Not necessary. It is included in the dump file set.

    FROMUSER

    SCHEMAS

    FULL

    FULL

    GRANTS

    EXCLUDE=GRANT

    HELP

    HELP

    IGNORE

    TABLE_EXISTS_ACTION

    INDEXES

    EXCLUDE=INDEX

    INDEXFILE

    SQLFILE with INCLUDE INDEX

    LOG

    LOGFILE

    PARFILE

    PARFILE

    RECORDLENGTH

    A parameter comparable to RECORDLENGTH is not needed.

    RESUMABLE

    A parameter comparable to RESUMABLE is not needed. It is automatically defaulted for privileged users.

    RESUMABLE_NAME

    A parameter comparable to RESUMABLE_NAME is not needed. It is automatically defaulted for privileged users.

    RESUMABLE_TIMEOUT

    A parameter comparable to RESUMABLE_TIMEOUT is not needed. It is automatically defaulted for privileged users.

    ROWS=N

    CONTENT=METADATA_ONLY

    ROWS=Y

    CONTENT=ALL

    SHOW

    SQLFILE

    SKIP_UNUSABLE_INDEXES

    SKIP_UNUSABLE_INDEXES

    STATISTICS

    A parameter comparable to STATISTICS is not needed. If the source table has statistics, they are imported.

    STREAMS_CONFIGURATION

    STREAMS_CONFIGURATION

    STREAMS_INSTANTIATION

    A parameter comparable to STREAMS_INSTANTIATION is not needed.

    TABLES

    TABLES

    TABLESPACES

    This parameter still exists, but some of its functionality is now performed using the TRANSPORT_TABLESPACES parameter.

    TOID_NOVALIDATE

    A command comparable to TOID_NOVALIDATE is not needed. OIDs are no longer used for type validation.

    TOUSER

    REMAP_SCHEMA

    TRANSPORT_TABLESPACE

    TRANSPORT_TABLESPACES (see command description)

    TTS_OWNERS

    A parameter comparable to TTS_OWNERS is not needed because the information is stored in the dump file set.

    USERID

    A parameter comparable to USERID is not needed. This information is supplied as the username/password when you invoke Import.

    VOLSIZE

    A parameter comparable to VOLSIZE is not needed because tapes are not supported.

  • 使用INCLUDE,EXCLUDE参数来实现更加灵活的对象筛选操作.

    INCLUDE 是包含且仅包含的对象条件;EXCLUDE 是排除的对象条件.

    INCLUDE,EXCLUDE 的条件表达式在windows环境里不需要输入转义字符,UNIX/LINUX环境下一定需要使用转义字符'/';下面通过linux环境下的几个例子来说明一下INCLUDE,EXCLUDE的使用方法.

    Syntax and Description

    EXCLUDE=object_type[:name_clause] [, ...]

    Name_clause是一个SQL 表达式语句,大致可以有下面几个格式:

    EXCLUDE=SCHEMA:"='HR'"

    EXCLUDE=VIEW

    EXCLUDE=PACKAGE

    EXCLUDE=FUNCTION

    EXCLUDE=TABLE

    EXCLUDE=INDEX

    EXCLUDE=PROCEDURE

    我们可以使用'=' 'LIKE' 'IN()'等方式来书写表达式,举几个例子:

    EXCLUDE=SCHEMA:"='HR'"

    LINUX格式: EXCLUDE=SCHEMA:/"/=/'HR/'/"

    导出时不包括HR用户的数据

    EXCLUDE=TABLE:" LIKE 'EMP_%'"

    UNIX格式:EXCLUDE=TABLE:/" LIKE /'EMP_%/'/"

    导出是不包括表名称以'EMP_'开头的表,例如不导出 EMP_USERS等等.

    EXCLUDE=INDEX:" IN ('PK_EMP','PK_CUST','PK_WORK')"

    UNIX格式: EXCLUDE=INDEX:/" IN /(/'PK_EMP/',/'PK_CUST/',/'PK_WORK/'/)/"

    导出不包括PK_EMP,PK_CUST,PK_WORK的索引

    EXCLUDE=VIEW,PACKAGE, FUNCTION

    导出是不包括VIEW,PACKAGE,FUNCTION等类型的对象

  • 请使用浏览器的分享功能分享到微信等