首页 > 其他分享 >EXPDP之INCLUDE参数解析

EXPDP之INCLUDE参数解析

时间:2023-01-17 21:31:17浏览次数:52  
标签:解析 EXPDP LEO leo SYS orcl150 TABLE INCLUDE SCHEMA

文档课题:EXPDP之INCLUDE参数解析.
应用场景:将A库某schema中的部分表导入到B库某schema中.
语法如下:
1INCLUDE = object_type[:name_clause] [, ...]
测试过程:
数据库:oracle 11.2.0.4
1、建测试表
新建用户及两个测试表.
SYS@orcl150> show user
USER is "SYS"
SYS@orcl150> create user leo identified by leo;

User created.

SYS@orcl150> grant connect,resource,unlimited tablespace to leo;

Grant succeeded.
SYS@orcl150> select default_tablespace,temporary_tablespace,username from dba_users where username='LEO';

DEFAULT_TABLESPACE TEMPORARY_TABLESPACE USERNAME
------------------------------ ------------------------------ ------------------------------
USERS TEMP LEO

SYS@orcl150> conn leo/leo
Connected.
LEO@orcl150> create table test1 (id number(4),name varchar2(20));

Table created.

LEO@orcl150> create table test2 (id number(4),name varchar2(20));

Table created.
2、insert数据
--给测试表插入数据.
LEO@orcl150> insert into test1 values (1,'alina');

1 row created.

LEO@orcl150> insert into test2 values (1,'henrry');

1 row created.

LEO@orcl150> commit;

Commit complete.
3、导出数据
仅导出Leo中的test1、test2两张表.
[oracle@leo-oel150 ~]$ expdp \" / as sysdba \" directory=DATA_PUMP_DIR dumpfile=leo_test.dmp schemas=leo include=table:\"like \'%TEST%\'\" logfile=expdp.log

Export: Release 11.2.0.4.0 - Production on Tue Jan 17 15:37:31 2023

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
Starting "SYS"."SYS_EXPORT_SCHEMA_01": "/******** AS SYSDBA" directory=DATA_PUMP_DIR dumpfile=leo_test.dmp schemas=leo include=table:"like '%TEST%'" logfile=expdp.log
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 128 KB
Processing object type SCHEMA_EXPORT/TABLE/TABLE
. . exported "LEO"."TEST1" 5.453 KB 1 rows
. . exported "LEO"."TEST2" 5.453 KB 1 rows
Master table "SYS"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_SCHEMA_01 is:
/u01/app/oracle/admin/orcl150/dpdump/leo_test.dmp
Job "SYS"."SYS_EXPORT_SCHEMA_01" successfully completed at Tue Jan 17 15:37:36 2023 elapsed 0 00:00:05
4、导入数据
--通过remap_schema将导出的表导入hr用户.
[oracle@leo-oel150 ~]$ impdp \" / as sysdba \" dumpfile=leo_test.dmp directory=DATA_PUMP_DIR remap_schema=leo:hr logfile=impdp.log

Import: Release 11.2.0.4.0 - Production on Tue Jan 17 15:43:04 2023

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_FULL_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_FULL_01": "/******** AS SYSDBA" dumpfile=leo_test.dmp directory=DATA_PUMP_DIR remap_schema=leo:hr logfile=impdp.log
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "HR"."TEST1" 5.453 KB 1 rows
. . imported "HR"."TEST2" 5.453 KB 1 rows
Job "SYS"."SYS_IMPORT_FULL_01" successfully completed at Tue Jan 17 15:43:05 2023 elapsed 0 00:00:01
5、验证数据
--查看hr用户导入的表数据.
[oracle@leo-oel150 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Jan 17 15:44:02 2023

Copyright (c) 1982, 2013, Oracle. 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

HR@orcl150> select * from test1;

ID NAME
---------- --------------------
1 alina

HR@orcl150> select * from test2;

ID NAME
---------- --------------------
1 henrry

相关语句:
expdp \'/ as sysdba\' directory=DATA_PUMP_DIR dumpfile=hr_t.dmp INCLUDE=TABLE:\"IN \(\'T\'\)\" SCHEMAS=HR LOGFILE=expdp_T.log
参考网址:
https://www.cnblogs.com/xidabei/p/7553782.html

标签:解析,EXPDP,LEO,leo,SYS,orcl150,TABLE,INCLUDE,SCHEMA
From: https://blog.51cto.com/u_12991611/6017835

相关文章