Oracle expdp/impdp使用示例
使用EXPDP和IMPDP时应该注意的事项: EXP和IMP是客户端工具程序,它们既可以在客户端使用,也可以在服务端使用。 EXPDP和IMPDP是服务端的工具程序,他们只能在ORACLE服务端使用,不能在客户端使用。 IMP只适用于EXP导出的文件,不适用于EXPDP导出文件;IMPDP
使用EXPDP和IMPDP时应该注意的事项:
EXP和IMP是客户端工具程序,它们既可以在客户端使用,也可以在服务端使用。
EXPDP和IMPDP是服务端的工具程序,他们只能在ORACLE服务端使用,不能在客户端使用。
IMP只适用于EXP导出的文件,不适用于EXPDP导出文件;IMPDP只适用于EXPDP导出的文件,而不适用于EXP导出文件。
expdp或impdp命令时,可暂不指出用户名/密码@实例名 as 身份,然后根据提示再输入,如:
expdp schemas=scott dumpfile=expdp.dmp DIRECTORY=dpdata1;
一、创建逻辑目录,该命令不会在操作系统创建真正的目录,最好以system等管理员创建。
create or replace directory dpdata1 as 'd:\test\dump';
二、查看管理理员目录(同时查看操作系统是否存在,因为Oracle并不关心该目录是否存在,如果不存在,则出错)
select * from dba_directories;
三、给scott用户赋予在指定目录的操作权限,最好以system等管理员赋予。
grant read,write on directory dpdata1 to scott;
四、导出数据
1)按用户导
expdp system/managerdirectory=dumpdir dumpfile=expdp.dmps chemas=scott;
2)并行进程parallel
expdp system/manager directory=dumpdir dumpfile=para_export%u.dmp parallel=2 job_name=scott3
3)按表名导
expdp system/manager directory=dumpdir dumpfile=expdp.dmp DIRECTORY=dpdata1;
4)按查询条件导
expdp system/manager directory=dumpdir dumpfile=expdp.dmp Tables=emp query='WHERE deptno=20';
5)按表空间导
expdp system/manager directory=dumpdirdumpfile=tablespace.dmp TABLESPACES=temp,example;
6)导整个数据库
expdp system/manager directory=dumpdirdumpfile=full.dmp FULL=y;
7)计算导出作业所需要的空间,默认采用blocks method
expdp system/system directory=dumpdir full=y estimate_only=y estimate=[statistics|blocks]
8)只导出表结构
expdp system/manager directory=dumpdir dumpfile=expdp.dmp schemas=hruser content=metadata_only
五、导入数据
1)导到指定用户下
impdp system/manager directory=dumpdir dumpfile=expdp.dmp SCHEMAS=scott;
2)改变表的owner
impdp system/manager directory=dumpdir dumpfile=expdp.dmp TABLES=scott.dept REMAP_SCHEMA=scott:viin REMAP_TABLESPACE=users:pay
3)导入表空间
impdp system/manager directory=dumpdir dumpfile=expdp.dmp TABLESPACES=example;
4)导入数据库
impdb system/manager directory=dumpdir dumpfile=expdp.dmp FULL=y;
5)追加数据
impdp system/manager directory=dumpdir dumpfile=expdp.dmp SCHEMAS=system TABLE_EXISTS_ACT
关于TABLE_EXISTS_ACT
六、传输表空间
1)验证表空间是否自包含
execute sys.dbms_tts.transport_set_check('USERS',true)
2)将表空间置于只读状态
alter tablespace users read only
3)导出迁移表空间的目录元数据,并且将导出文件和迁移表空间对应的数据文件拷贝到目标数据库的指定目录下
expdp system/manager directory=dumpdir dumpfile=expdp.dmp transport_tablespaces=users
4)在目标数据库导入迁移表空间
impdp system/manager directory=dumpdir dumpfile=expdp.dmp transport_datafiles=users01.dbf
备注:
1、客户端字符集NLS_LANG=language_territory.charset应该与数据库字符集一样,至少客户端和目标数据库字符集应该是源数据库字符集的严格超集,但是这种情况会存在字符集转换。
2、从11g版本迁移到10g版本,需要在expdp时指定参数version=10.2。
3、导出导入时可以指定job_name、logfile参数,以便查询视图dba_datapump_jobs跟踪导出导入,并且在结束后,查询日志是否有失败和警告。
4、改变一个对象的owner, 以及对象所在的tablespace, oracle 提供了以下两种方式:
exp/imp 的 fromuser touser
expdp/impdp 的 remap_schema remap_tablespace

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.

Oracle database paging uses ROWNUM pseudo-columns or FETCH statements to implement: ROWNUM pseudo-columns are used to filter results by row numbers and are suitable for complex queries. The FETCH statement is used to get the specified number of first rows and is suitable for simple queries.

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

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.

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.
