暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

12C expdp view导出成table

原创 章芋文 2013-10-31
1057
12c中expdp能将视图导出成table,使用views_as_tables参数即可,导出的dump文件也可导入到库中。
下面是测试过程:
[code]SQL> create view dp_view_test as select * from N_OBJ where OBJECT_ID<5000;

View created.
SQL> select object_name,object_type from user_objects where object_name='DP_VIEW_TEST';

OBJECT_NAME OBJECT_TYPE
---------------------------------------- -----------------------
DP_VIEW_TEST VIEW
SQL> select count(*) from dp_view_test;

COUNT(*)
----------
4996

SQL> create directory dmpdir as '/oracle/12c/oradata/dump';

Directory created.[/code]
数据泵导出
[code][oracle@ora12c dump]$ expdp c##awen/oracle dumpfile=vi_to_tb.dmp directory=dmpdir logfile=vi_to_tb.log views_as_tables=dp_view_test:n_obj

Export: Release 12.1.0.1.0 - Production on Fri Aug 30 17:41:03 2013

Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

WARNING: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database.

Starting "C##AWEN"."SYS_EXPORT_TABLE_01": c##awen/******** dumpfile=vi_to_tb.dmp directory=dmpdir logfile=vi_to_tb.log views_as_tables=dp_view_test:n_obj
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE_DATA
Total estimation using BLOCKS method: 13 MB
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE
. . exported "C##AWEN"."DP_VIEW_TEST" 171.1 KB 4996 rows
Master table "C##AWEN"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for C##AWEN.SYS_EXPORT_TABLE_01 is:
/oracle/12c/oradata/dump/vi_to_tb.dmp
Job "C##AWEN"."SYS_EXPORT_TABLE_01" successfully completed at Fri Aug 30 17:41:19 2013 elapsed 0 00:00:13[/code]
删除视图DP_VIEW_TEST
SQL> drop view DP_VIEW_TEST;

View dropped.
导入dump
[code][oracle@ora12c dump]$ impdp c##awen/oracle VIEWS_AS_TABLES=dp_view_test dumpfile=vi_to_tb.dmp directory=dmpdir TRANSFORM=DISABLE_ARCHIVE_LOGGING:Y

Import: Release 12.1.0.1.0 - Production on Fri Aug 30 17:46:49 2013

Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

WARNING: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database.

Master table "C##AWEN"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "C##AWEN"."SYS_IMPORT_TABLE_01": c##awen/******** VIEWS_AS_TABLES=dp_view_test dumpfile=vi_to_tb.dmp directory=dmpdir TRANSFORM=DISABLE_ARCHIVE_LOGGING:Y
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE_DATA
. . imported "C##AWEN"."DP_VIEW_TEST" 171.1 KB 4996 rows
Job "C##AWEN"."SYS_IMPORT_TABLE_01" successfully completed at Fri Aug 30 17:46:57 2013 elapsed 0 00:00:05[/code]
另:其中TRANSFORM在12c中有很多功能,后面会讲到
[code]SQL> select count(*) from DP_VIEW_TEST;

COUNT(*)
----------
4996
SQL> col OBJECT_NAME for a40
SQL> select object_name,object_type from user_objects where object_name='DP_VIEW_TEST';

OBJECT_NAME OBJECT_TYPE
---------------------------------------- -----------------------
DP_VIEW_TEST TABLE[/code]
另外还有一个LOGTIME=ALL
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论