oracle expdp导出和impdp导入使用方法
本篇介绍一下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';
第二步 查看逻辑目录是否创建成功
此时应该在再查看“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='WHERE id < 20'
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.] 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 例:expdp answer/answer tables=a_answer directory=my_dbdata dumpfile=expCASES_%U.dmp parallel=4 注意:dumpfile 在并行模式下,状态屏幕将显示四个工作进程。(在默认模式下,只有一个进程是可见的)所有的工作进程同步取出数据,并在状态屏幕上显示它们的进度。 分离访问数据文件和转储目录文件系统的输入/输出通道是很重要的。否则,与维护Data |
导入-impdp参数说明
TABBLE_EXISTS_ACTION |
TABBLE_EXISTS_ACTION={SKIP 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 |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.
