实验目标:运用数据泵导出导入单表实验演练.
运用场景:客户需要在测试库创建与生产库同样的视图,但该视图所依赖的有些表是搭建测试库之后才在生产库创建的,此时就需要将此类表通过数据泵的方式导入到测试库.
源端IP:192.168.133.160
目标端IP:192.168.133.190
源端数据检查:
SQL> conn liujun/liujun;
Connected.
SQL> select * from test
NAME JOB_TITLE
-------------------- ---------------
cherry acc
jack sal
SQL> conn leo/leo;
Connected.
SQL> select * from emp;
SAL EMPNO JOB
---------- ----- -----
7000 7839 CEO
8000 7788 leader
SQL> create directory empdp as '/home/oracle/';
Directory created.
[oracle@hisdb1:/home/oracle]$ expdp \'/ as sysdba\' directory=empdp dumpfile=tables.dmp logfile=tables.log tables=liujun.test,leo.emp
Export: Release 11.2.0.4.0 - Production on
Wed Jul 20 14:31:57 2022
Copyright (c) 1982, 2011, Oracle and/or its
affiliates. All rights reserved.
Connected to: Oracle Database 11g
Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application
Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing
options
Starting
"SYS"."SYS_EXPORT_TABLE_01": "/******** AS SYSDBA" directory=empdp dumpfile=tables.dmp logfile=tables.log tables=liujun.test,leo.emp
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 128 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "LEO"."EMP" 5.828 KB 2 rows
. . exported "LIUJUN"."TEST" 5.437 KB 2 rows
Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
/home/oracle/tables.dmp
Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at Wed
Jul 20 14:32:06 2022 elapsed 0 00:00:08
[oracle@hisdb1:/home/oracle]$ ll
total 116
drwxr-xr-x 2 oracle oinstall 4096 Jul 15 09:43 dbbak
drwxr-xr-x. 2 oracle oinstall 6 Jun 19 10:57 scripts
-rw-r----- 1 oracle asmadmin 110592 Jul 20 14:32 tables.dmp
-rw-r--r-- 1 oracle asmadmin 1268 Jul 20 14:32 tables.log
[root@hisdb1 oracle]# scp tables.dmp oracle@192.168.133.190:/home/oracle
The authenticity of host '192.168.133.190 (192.168.133.190)' can't be established.
ECDSA key fingerprint is SHA256:qD8qCc9Sa9K3sFBVQAiLkslJTSFZ1kmrRRLDZYvh8I4.
ECDSA key fingerprint is MD5:aa:c2:3c:5b:e2:15:6f:fc:14:28:06:97:58:aa:05:80.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.133.190' (ECDSA) to the list of known hosts.
oracle@192.168.133.190's password:
tables.dmp
目标端操作:
SQL> create user leo identified by leo;
User created.
SQL> grant connect,resource to leo;
Grant succeeded.
SQL> create user liujun identified by liujun;
User created.
SQL> grant connect,resource to liujun;
Grant succeeded.
SQL> grant read,write on directory impdp to leo,liujun;
Grant succeeded.
[oracle@prometheus ~]$ impdp \'/ as sysdba\' directory=impdp dumpfile=tables.dmp logfile=tables.log tables=liujun.test,leo.emp
Import: Release 11.2.0.4.0 - Production on Wed Jul 20 14:44:26 2022
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
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
Master table "SYS"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_TABLE_01": "/******** AS SYSDBA" directory=impdp dumpfile=tables.dmp logfile=tables.log tables=liujun.test,leo.emp
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "LEO"."EMP" 5.828 KB 2 rows
. . imported "LIUJUN"."TEST" 5.437 KB 2 rows
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SYS"."SYS_IMPORT_TABLE_01" successfully completed at Wed
Jul 20 14:44:31 2022 elapsed 0 00:00:03
SQL> conn leo/leo;
Connected.
SQL> select * from emp;
SAL EMPNO JOB
---------- ---------- ----------
7000 7839 CEO
8000 7788 leader
SQL> conn liujun/liujun;
Connected.
SQL> select * from test;
NAME JOB_TITLE
-------------------- --------------------
cherry acc
jack sal
成功导入.
如果源库和目标库对应的表空间或shema不同,需使用以下进行转换
remap_schema=schema1:schema2 源shema:目标库schema
remap_tablespace=tablespace1:tablespace2 源表空间:目标表空间