search
HomeDatabaseMysql Tutorialoracle expdp导出和impdp导入使用方法

oracle expdp导出和impdp导入使用方法

May 18, 2018 pm 02:50 PM
oracleInstructionsimportExport

本篇介绍一下oracle expdp导出、impdp导入的使用方法 准备工作 导出-expdp 导入-impdp 导出-expdp参数说明 导入-impdp参数说明 准备工作 oracle中的expdp导出、impdp导入的使用之前,都得先完成以下三个步骤 第一步 以管理员身份,创建逻辑目录 create direc

本篇介绍一下oracle expdp导出、impdp导入的使用方法

准备工作

导出-expdp

导入-impdp

导出-expdp参数说明

导入-impdp参数说明

准备工作

oracle中的expdp导出、impdp导入的使用之前,都得先完成以下三个步骤

第一步 以管理员身份,创建逻辑目录

create directory my_dbdata as 'D:/my_dbdata';

第二步 查看逻辑目录是否创建成功

oracle expdp导出和impdp导入使用方法

此时应该在再查看“D:/my_dbdata”这个磁盘物理路径是否存在。因为oracle创建时并不关心该磁盘目录是否存在,如果不存在,则在后续的操作中会报错

第三步 赋予导出用户的逻辑目录操作权限

比如我要导出一个用户名为“answer”的库,则需要用管理员来赋予“answer”用户对于逻辑目录的操作权限。

grant read,write on directory my_dbdata to answer;

操作系统为windows,则打开cmd窗口,若为linux或其他unix系统,则直接在命令行操作

特别注意:在expdp、impdp命令使用时,不要习惯性的在命令末尾加上分号“;”,会导致不经意间出现错误。

          曾经我进行导入操作是,最后加了个分号,语句如下:

impdp eppapp0805/eppapp0805 DIRECTORY=epp_data DUMPFILE=eppapptest_88_20130805.dmp 
    remap_schema=eppapptest:eppapp0805;

    看见了没,最后那个参数是remap_schema=eppapptest:eppapp0805,表示该dmp包是从eppapptest用户导出来的,要把这个dmp包导入到用户eppapp0805去,结果,导入时oracle把“eppapp0805;”连分号一起当成用户名了,一看现有库中不存在这个用户,就创建新用户,然后就创建了一个带分号结尾的用户。而这个用户还不能登录,因为有特殊字符,非常的郁闷

导出-expdp

1)按用户导出

expdp answer/answer@orcl schemas=answer dumpfile=answer.dmp DIRECTORY=my_dbdata

2)按表名导出

expdp answer/answer@orcl TABLES=a_answer,a_question 
    dumpfile=m_table.dmp DIRECTORY=my_dbdata

3)按查询条件导出

expdp answer/answer@orcl directory=my_dbdata dumpfile=exp_by_query.dmp 
    tables=a_answer query=&#39;WHERE id < 20&#39;

4)按表空间导出

expdp answer/answer DIRECTORY=my_dbdata DUMPFILE=tablespace.dmp TABLESPACES=user

5)整个数据库导出

expdp answer/answer DIRECTORY=my_dbdata DUMPFILE=full.dmp FULL=y

导入-impdp

1)导入到指定用户下

impdp answer/answer DIRECTORY=my_dbdata DUMPFILE=answer.dmp SCHEMAS=answer

2)如果导出的用户表空间跟导入的用户表空间不一致,则按下面的方法导入

impdp answer/answer DIRECTORY=my_dbdata DUMPFILE=answer.dmp 
    REMAP_SCHEMA=user1(导出时的所属用户名):user2(导入时的所属用户名)

3)只导入dmp文件中的某几个表

impdp answer/answer DIRECTORY=my_dbdata DUMPFILE=answer.dmp 
    TABLES=a_answer,a_question

4)导入表空间

impdp answer/answer DIRECTORY=my_dbdata DUMPFILE=tablespace.dmp TABLESPACES=user

5)导入整个数据库

impdb answer/answer DIRECTORY=my_dbdata DUMPFILE=full.dmp FULL=y;

6)追加数据

impdp answer/answer DIRECTORY=my_dbdata DUMPFILE=answer.dmp 
    SCHEMAS=answer TABLE_EXISTS_ACTION=APPEND

导出-expdp参数说明

CONTENT

用于指定要导出的内容,默认为ALL

CONTENT=ALL:导出对象定义和所有数据

        DATA_ONLY:只导出数据

        METADATA_ONLY:只导出对象定义

DIRECTORY

指定逻辑目录的名称,为之前创建的逻辑目录。

EXCLUDE

用于指定执行操作时释放要排除的对象类型或相关对象

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

object_type用于指定要排除的对象类型,name_clause用于指定要排除的具体对象

例:EXCLUDE=TABLE:EMP


EXCLUDE和INCLUDE不能同时使用

INCLUDE

导出时包含指定的类型

例:INCLUDE=TABLE_DATA,

   INCLUDE=TABLE:"LIKE 'TAB%'"

   INCLUDE=TABLE:”NOT LIKE ‘TAB%’”…


EXCLUDE和INCLUDE不能同时使用

FILESIZE

指定导出文件的大小,默认为0,表示没有大小限制(单位为bytes)

TABLESPACE

指定一个表空间导出

QUERY

QUERY=[schema.]
[table_name:] query_clause

schema为指定方案名,table_name为指定表名,query_clause用于指定条件限制子句


例:expdp answer/answer directory=my_dbdata dumpfiel=answer.dmp tables=a_answer query=’WHERE deptno=20’


QUERY选项不能与CONNECT=METADATA_ONLY,EXTIMATE_ONLY,TRANSPORT_TABLESPACES等选项同时使用.


PARALLEL

并行操作:指定执行导出操作的并行进程个数,默认值为1


您可以通过PARALLEL
参数为导出使用一个以上的线程加速作业。每个线程创建一个单独的转储文件,因此参数dumpfile
应当拥有和并行度一样多的项目。您可以指定通配符作为文件名,而不是显式地输入各个文件名,


例:expdp answer/answer tables=a_answer directory=my_dbdata dumpfile=expCASES_%U.dmp parallel=4


注意:dumpfile
参数拥有一个通配符%U,它指示文件将按需要创建,格式将为expCASES_nn.dmp,其中nn 从01 开始,然后按需要向上增加。


在并行模式下,状态屏幕将显示四个工作进程。(在默认模式下,只有一个进程是可见的)所有的工作进程同步取出数据,并在状态屏幕上显示它们的进度。


分离访问数据文件和转储目录文件系统的输入/输出通道是很重要的。否则,与维护Data
Pump 作业相关的开销可能超过并行线程的效益,并因此而降低性能。并行方式只有在表的数量多于并行值并且表很大时才是有效的。



导入-impdp参数说明

TABBLE_EXISTS_ACTION

TABBLE_EXISTS_ACTION={SKIP
| APPEND | TRUNCATE | FRPLACE }


SKIP:导入时会跳过已存在的对象

APPEND:导入时会追加数据

TRUNCATE:导入时会截断表,然后追加新的数据

REPLACE:导入时会删除已存在的表,重建表再追加数据

REMAP_SCHEMA

用于将源方案中的所有对象装载到目标方案中。

例:如果dmp文件导出时对应用户名为 user1,

    导入时对应用户名为user2,

则因为用户名不一致而无法导入,需要这样用

REMAP_SCHEMA=user1:user2

REMAP_TABLESPACE

将源表空间的所有对象导入到目标表空间

REMAP_TABLESPACE=source_tablespace:target:tablespace

REMAP_DATAFILE

将源数据文件转变为目标数据文件,在不同平台之间搬移表空间可能需要该选项

REMAP_DATAFIEL=source_datafie:target_datafile

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor