expdp之include参数——实现表级别的expdp操作
2024-08-29 18:22:50
需求是这样的:想将A库的某schema中的一部分表导入到B库的某schema中。
第一可以想到的是使用expdp工具,但是如何只挑选某些表呢,通过查看官方文档,include参数可以实现该需求。
include语法如下:
INCLUDE = object_type[:name_clause] [, ...]
query具体的说明请参见官方文档。
现测试如下:
1、数据库版本,
> select * from v$version; BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production TNS for 64-bit Windows: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
2、在scott中新建三个测试表,为了能够使用query参数,此处特意以“test+数字”命名测试表
> create table scott.test1 (id number(4), description varchar2(100)); Table created SQL> create table scott.test2 (id number(4), description varchar2(100)); Table created SQL> create table scott.test3 (id number(4), description varchar2(100)); Table created
3、给三个测试表插入数据
> select * from scott.test1; ID DESCRIPTION
----- --------------------------------------------------------------------------------
1 test table no.1
2 test table no.1 SQL> select * from scott.test2; ID DESCRIPTION
----- --------------------------------------------------------------------------------
1 test table no.2
2 test table no.2
3 test table no.2 SQL> select * from scott.test3; ID DESCRIPTION
----- --------------------------------------------------------------------------------
1 test table no.3
2 test table no.3
3 test table no.3
4 test table no.3
4、新建被导入的schema
> create user scott_test identified by scotttest default tablespace users; User created
5、仅导出scott中的test1、test2、test3三张表
expdp \"/as sysdba\" dumpfile=scotttesttbl.dmp schema=scott include=table:\"like '%TEST%'\"
7、从上图看,确实仅导出了刚才新建的三张表,我们可以将这个dmp文件倒回到scott_test用户下验证
先给scott_test用户赋予resource权限
> grant resource to scott_test;
Grant succeeded
通过remap_schema将scott用户下的表导入scott_test用户下
impdp \"/as sysdba\" dumpfile=scotttesttbl.dmp remap_schema=scott:soctt_test
8、查看scott_test用户下的所有表
> grant connect to scott_test; Grant succeeded
==========================
> select user from dual; USER
------------------------------
SCOTT_TEST
==========================
> select * from user_tables; TABLE_NAME TABLESPACE_NAME CLUSTER_NAME IOT_NAME STATUS PCT_FREE ... ------------------------------ ------------------------------ ------------------------------ ------------------------------ -------- ---------- ...
TEST3 USERS VALID 10 ...
TEST1 USERS VALID 10 ...
TEST2 USERS VALID 10 ...
SQL>
实验成功。
花絮:开始以为实现该功能是需要query参数,后来发现不行,query是实现更细致力度的参数,可以筛选表中符合查询条件的某些内容。
最新文章
- maven添加自己的jar包到本地仓库
- OSG中的HUD
- Oracle数据创建表空间
- Java Ant build.xml详解
- C# 截取带路径的文件名字,扩展名,等等 的几种方法
- EasyUI 兼容 IE6 方法总结
- SharePoint 使用技巧汇总与讨论
- Android 开发TCP协议时,报错NetworkOnMainThreadException
- HTML、CSS(小笔记)
- 【原创】Aduino小车玩法全记录
- bzoj1206-[HNOI2005]虚拟内存
- oracle 根据在线更新分区。
- 激活win10专业版
- html 替换元素
- Django配置富文本编辑器kindeditor
- shell编程学习笔记(一):编写我的第一段代码
- CentOS7系统下YUM安装安装Mongodb 3.4
- iOS 工程自动化 - OCLint
- 笔记本用HDMI、VGA连接高清电视全过程实录2——各种问题
- docker 磁盘清理 相关
热门文章
- 关于Apache的配置方法和步骤
- node.js学习6---第三方依赖(模块或者说是包)的导入 npm 以及 cnpm命令的使用
- SharePoint Framework 在web部件中使用已存在的JavaScript库 - 捆绑打包和外部引用
- 1011. World Cup Betting (20)
- Shell 函数相关
- JAVA8之数据流Stream
- windows平台python svn模块的一个小 bug
- 2019-04-28-day042-HTML初识
- 单链表sLinkList类,模板类
- Windows10 VS2017 C++模拟点击按键