ORACLE 12C可以通过expdp导出view数据
浏览:3896次 出处信息
有时候,多么的希望ORACLE能够导出某个视图中的数据,然后通过这个视图来迁移需要的数据,现在ORACLE 12C通过expdp的views_as_tables来实现了该功能,把视图当作一个普通表从而导出数据,导入的时候直接和一个正常表一样,通过视图的导出,表的导入来实现相关需求
准备测试环境
SQL> SELECT* FROMV$VERSION; BANNER CON_ID -------------------------------------------------------------------------------- ---------- Oracle Database12c Enterprise Edition Release 12.1.0.0.2 - 64bit Beta 0 PL/SQL Release 12.1.0.0.2 - Beta 0 CORE 12.1.0.0.2 Beta 0 TNS forLinux: Version 12.1.0.0.2 - Beta 0 NLSRTL Version 12.1.0.0.2 - Beta SQL> createtablet_lx asselect* fromv$log; Tablecreated. SQL> createtablet_xl asselect* fromv$logfile; Tablecreated. SQL> createviewv_xifenfei as 2 SELECTthread#, 3 a.sequence#, 4 a.group#, 5 TO_CHAR (first_change#, '9999999999999999') "SCN", 6 a.status, 7 MEMBER 8 FROMt_lx a, t_xl b 9 WHEREa.group# = B.GROUP# 10 ORDERBYa.sequence# DESC; Viewcreated. SQL> col member fora50 SQL> setlines 134 SQL> select* fromv_xifenfei; THREAD# SEQUENCE# GROUP# SCN STATUS MEMBER ---------- ---------- ---------- ----------------- ---------------- ------------------------------------------- 1 30 3 391892 CURRENT /u01/app/oracle/oradata/xifenfei/redo03.log 1 29 2 377363 INACTIVE /u01/app/oracle/oradata/xifenfei/redo02.log 1 28 1 374892 INACTIVE /u01/app/oracle/oradata/xifenfei/redo01.log
expdp结合VIEWS_AS_TABLES导出视图
[oracle@xifenfei ~]$ expdp xff/xifenfeiviews_as_tables=v_xifenfei directory=data_pump_dir dumpfile=xifenfei.dmp Export: Release 12.1.0.0.2 - Beta on Sun Dec 16 07:56:48 2012 Copyright (c) 1982, 2012, Oracle and/orits affiliates. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 - 64bit Beta With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "XFF"."SYS_EXPORT_TABLE_01":xff/******** views_as_tables=v_xifenfei directory=data_pump_dir dumpfile=xifenfei.dmp Estimate inprogress using BLOCKS method... Processing object typeTABLE_EXPORT/VIEWS_AS_TABLES/TABLE_DATA Total estimation using BLOCKS method: 16 KB Processing object typeTABLE_EXPORT/VIEWS_AS_TABLES/TABLE . . exported "XFF"."V_XIFENFEI" 7.390 KB 3 rows Master table "XFF"."SYS_EXPORT_TABLE_01"successfully loaded/unloaded ****************************************************************************** Dump filesetforXFF.SYS_EXPORT_TABLE_01 is: /u01/app/oracle/admin/xifenfei/dpdump/xifenfei.dmp Job "XFF"."SYS_EXPORT_TABLE_01"successfully completed at Sun Dec 16 07:58:17 2012 elapsed 0 00:00:56
impdp导入数据
[oracle@xifenfei ~]$ impdp xff/xifenfeiremap_table=v_xifenfei:v_xff directory=data_pump_dir dumpfile=xifenfei.dmp Import: Release 12.1.0.0.2 - Beta on Sun Dec 16 08:06:06 2012 Copyright (c) 1982, 2012, Oracle and/orits affiliates. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 - 64bit Beta With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "XFF"."SYS_IMPORT_FULL_01"successfully loaded/unloaded Starting "XFF"."SYS_IMPORT_FULL_01":xff/******** remap_table=v_xifenfei:v_xff directory=data_pump_dir dumpfile=xifenfei.dmp Processing object typeTABLE_EXPORT/VIEWS_AS_TABLES/TABLE Processing object typeTABLE_EXPORT/VIEWS_AS_TABLES/TABLE_DATA . . imported "XFF"."V_XFF" 7.390 KB 3 rows Job "XFF"."SYS_IMPORT_FULL_01"successfully completed at Sun Dec 16 08:06:20 2012 elapsed 0 00:00:10
验证数据
SQL> COL OBJECT_NAME FORA20 SQL> selectobject_type,object_name fromuser_objectS whereobject_name like'V_X%'; OBJECT_TYPE OBJECT_NAME ----------------------- -------------------- VIEW V_XIFENFEI TABLE V_XFF SQL> col member fora50 SQL> setlines 134 SQL> select* fromv_XFF; THREAD# SEQUENCE# GROUP# SCN STATUS MEMBER ---------- ---------- ---------- ----------------- ---------------- -------------------------------------------- 1 30 3 391892 CURRENT /u01/app/oracle/oradata/xifenfei/redo03.log 1 29 2 377363 INACTIVE /u01/app/oracle/oradata/xifenfei/redo02.log 1 28 1 374892 INACTIVE /u01/app/oracle/oradata/xifenfei/redo01.log
通过测试证明在12C中ORACLE的expdp/impdp可以实现导出视图数据,进入导入到[其他库]其他表中
建议继续学习:
- EXPDP:使用ESTIMATE_ONLY参数评估ESTIMATE性能 (阅读:1777)
- cursor_sharing参数对于expdp的性能影响 (阅读:1554)
- EXPDP 过程中的 SYS_XMLGEN 性能影响 (阅读:1544)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
扫一扫订阅我的微信号:IT技术博客大学习
文章信息
- 作者:惜分飞 来源: 惜分飞
- 标签: expdp view
- 发布时间:2012-12-21 13:31:11
近3天十大热文
- [55] Oracle MTS模式下 进程地址与会话信
- [55] IOS安全–浅谈关于IOS加固的几种方法
- [54] 如何拿下简短的域名
- [53] 图书馆的世界纪录
- [53] android 开发入门
- [52] Go Reflect 性能
- [49] 读书笔记-壹百度:百度十年千倍的29条法则
- [49] 【社会化设计】自我(self)部分――欢迎区
- [38] 程序员技术练级攻略
- [33] 视觉调整-设计师 vs. 逻辑