linuximpdp命令
linuximpdp命令详细介绍
impdp 是 Oracle 数据库在 Linux 系统下用于导入数据泵导出文件的命令行工具,它能把之前使用 expdp 工具导出的数据和元数据重新导入到目标数据库中。下面为你介绍其基本用法、常用参数以及示例。
基本语法
bash
impdp username/password@service_name directory_object dumpfile_name other_parameters
常用参数
username/password@service_name:指定用于连接目标数据库的用户名、密码和服务名。directory:指定存储导出文件的目录对象,该目录对象需要在数据库中预先创建。dumpfile:指定要导入的导出文件名。schemas:指定要导入的数据库模式,多个模式可用逗号分隔。tables:指定要导入的表名,多个表可用逗号分隔。remap_schema:用于将源模式中的对象导入到目标模式中,格式为remap_schema=source_schema:target_schema。remap_tablespace:用于将源表空间中的对象导入到目标表空间中,格式为remap_tablespace=source_tablespace:target_tablespace。logfile:指定导入日志文件的名称。
示例
1. 导入整个模式
bash
impdp scott/tiger@orcl dpump_dir scott.dmp scott import_scott.log
此命令会把 scott 模式的所有对象从 scott.dmp 文件导入到 orcl 服务的数据库里,同时会生成名为 import_scott.log 的日志文件。
2. 导入特定表
bash
impdp scott/tiger@orcl dpump_dir scott.dmp emp,dept import_tables.log
该命令会把 scott 模式下的 emp 和 dept 表从 scott.dmp 文件导入到 orcl 服务的数据库中,并且生成名为 import_tables.log 的日志文件。
3. 重映射模式
bash
impdp scott/tiger@orcl dpump_dir scott.dmp scott scott:new_scott import_remap_schema.log
这个命令会把 scott 模式的所有对象从 scott.dmp 文件导入到 orcl 服务的数据库中,同时将这些对象重映射到 new_scott 模式下,还会生成名为 import_remap_schema.log 的日志文件。
注意事项
- 要保证执行
impdp命令的用户具备相应的权限,例如DATAPUMP_IMP_FULL_DATABASE角色。 - 需确保目录对象在数据库中已存在,且该目录对象指向的物理目录对 Oracle 用户是可访问的。
- 若导入过程中遇到权限问题,可能需要联系数据库管理员进行权限调整。