Oracle 导入导出工具的基本使用

  • exp/imp的使用方法主要有三种方式(完全、用户、表),需要dba权限
  • EXP 完全

    [oracle@ystdb11g ~]$ exp system@ystdb file=/backups/full_exp_20200313.dmp 
    log=/backups/full_exp_20200313.log full=y
  • EXP 用户

    [oracle@ystdb11g ~]$ exp test@ystdb file=/backups/test_exp_20200313.dmp 
    log=/backups/test_exp_20200313.log owner=test
    
    Export: Release 11.2.0.4.0 - Production on Thu Mar 12 23:07:45 2020
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    Password:
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set
    
    About to export specified users ...
    . exporting pre-schema procedural objects and actions
    . exporting foreign function library names for user TEST
    . exporting PUBLIC type synonyms
    . exporting private type synonyms
    . exporting object type definitions for user TEST
    About to export TEST's objects ...
    . exporting database links
    . exporting sequence numbers
    . exporting cluster definitions
    . about to export TEST's tables via Conventional Path ...
    . . exporting table                          TTB01       5000 rows exported
    . . exporting table                          TTB02       6000 rows exported
    . . exporting table                          TTB03       7000 rows exported
    . . exporting table                          TTB04      10000 rows exported
    . . exporting table                          TTB05      15000 rows exported
    . exporting synonyms
    . exporting views
    . exporting stored procedures
    . exporting operators
    . exporting referential integrity constraints
    . exporting triggers
    . exporting indextypes
    . exporting bitmap, functional and extensible indexes
    . exporting posttables actions
    . exporting materialized views
    . exporting snapshot logs
    . exporting job queues
    . exporting refresh groups and children
    . exporting dimensions
    . exporting post-schema procedural objects and actions
    . exporting statistics
    Export terminated successfully without warnings.
  • EXP 表

    [oracle@ystdb11g ~]$ exp test@ystdb file=/backups/test_ttb01_exp_20200313.dmp 
    log=/backups/test_ttb01_exp_20200313.log tables=TTB01
    
    Export: Release 11.2.0.4.0 - Production on Thu Mar 12 23:23:05 2020
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    Password:
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set
    
    About to export specified tables via Conventional Path ...
    . . exporting table                          TTB01       5000 rows exported
    Export terminated successfully without warnings.
  • IMP 完全

    [oracle@ystdb11g ~]$ imp system@ystdb file=/backups/full_exp_20200313.dmp 
    log=/backups/full_imp_20200313.log full=y
  • IMP 用户

    [oracle@ystdb11g ~]$ imp test@ystdb file=/backups/test_exp_20200313.dmp 
    log=/backups/test_imp_20200313.log fromuser=test touser=test
    
    Import: Release 11.2.0.4.0 - Production on Thu Mar 12 23:49:14 2020
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    Password:
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    Export file created by EXPORT:V11.02.00 via conventional path
    import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
    . . importing table                        "TTB01"       5000 rows imported
    . . importing table                        "TTB02"       6000 rows imported
    . . importing table                        "TTB03"       7000 rows imported
    . . importing table                        "TTB04"      10000 rows imported
    . . importing table                        "TTB05"      15000 rows imported
    Import terminated successfully without warnings.
  • IMP 表

    [oracle@ystdb11g backups]$ imp test@ystdb file=/backups/test_ttb02_exp_20200313.dmp 
    log=/backups/test_ttb02_imp_20200313.log tables=TTB02
    
    Import: Release 11.2.0.4.0 - Production on Thu Mar 12 23:58:57 2020
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    Password:
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    Export file created by EXPORT:V11.02.00 via conventional path
    import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
    . importing TEST's objects into TEST
    . importing TEST's objects into TEST
    . . importing table                        "TTB02"       6000 rows imported
    Import terminated successfully without warnings.
  • EXP-00091: Exporting questionable statistics
    出现EXP-00091: Exporting questionable statistics的原因是因为客户端的字符集和数据库的字符集不一致,根据数据库的字符集修改客户端的字符集即可

    SQL> col value for a20
    SQL> select * from nls_database_parameters where parameter like 'NLS_CHAR%';
    
    PARAMETER               VALUE
    ------------------------------ --------------------
    NLS_CHARACTERSET           AL32UTF8
  • Linux系统临时修改,永久需要在Oracle用户的.bash_profile文件中增加

    [oracle@ystdb11g ~]$ export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
  • Windows系统临时修改,永久修改需要添加系统环境环境变量

    C:\Users\Falkon>set NLS_LANG=AMERICAN_AMERICA.AL32UTF8
  • 如果导出的dmp文件没有明确的命名和表示,那么我们将不能确认导出的方式是exp还是expdp,在使用impdp导入的时候将会报如下错误

    [oracle@ystdb11g backups]$ impdp test@ystdb file=/backups/test_exp_20200313.dmp 
    log=/backups/test_imp_20200313.log fromuser=test touser=test
    
    Import: Release 11.2.0.4.0 - Production on Fri Mar 13 00:02:32 2020
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    Password:
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    ORA-39002: invalid operation
    ORA-39070: Unable to open the log file.
    ORA-39088: file name cannot contain a path specification
  • 关于exp buffer的说明
    官网说明链接 https://docs.oracle.com/cd/A8...
    Default: operating system-dependent. See your Oracle operating system-specific documentation to determine the default value for this parameter.

    Specifies the size, in bytes, of the buffer used to fetch rows. As a result, this parameter determines the maximum number of rows in an array fetched by Export. Use the following formula to calculate the buffer size:

    buffer_size = rows_in_array * maximum_row_size

    If you specify zero, the Export utility fetches only one row at a time.
    Tables with LONG, LOB, BFILE, REF, ROWID, LOGICAL ROWID, DATE, or type columns are fetched one row at a time.
    Note: The BUFFER parameter applies only to conventional path Export. It has no effect on a direct path Export.

    Example
    This section shows an example of how to calculate buffer size.
    Consider that the following table is created:

    create table sample (name varchar(30), weight number);

    The maximum size of the name column is 30, plus 2 bytes for the indicator. The maximum size of the weight column is 22 (the size of the internal representation for Oracle numbers), plus 2 bytes for the indicator.
    Therefore, the maximum row size is 56 (30+2+22+2).
    To perform array operations for 100 rows, a buffer size of 5600 should be specified.

    对于数据量较大的可以通过设置buffer来增加导出的速度,具体的计算方式:需要导出的行数 * (每个字段的字节数+2)

你可能感兴趣的:(oracle数据库)