博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
通过shell解析dump生成parfile
阅读量:2446 次
发布时间:2019-05-10

本文共 4981 字,大约阅读时间需要 16 分钟。

当我们得到一个dump文件的时候,总是有些不太确定dump文件中是否含有一些我们原本不希望出现的表,如果在未知的情况下对dump文件进行操作时很危险的,比如我们想要得到的是表结构的信息。如果不指定需要的表,会把当前schema下所有的Object对象的信息都导出。一般的操作中,建议还是使用parfile。

[ora11g@rac1 dbm_lite]$ exp n1/n1 file=n1_ddl.dmp rows=n  statistics=none

Export: Release 11.2.0.3.0 - Production on Tue Aug 26 07:21:57 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses AL32UTF8 character set (possible charset conversion)
Note: table data (rows) will not be exported

About to export specified users ...

. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user N1
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user N1
About to export N1's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export N1's tables via Conventional Path ...
. . exporting table                     BIG_INSERT
. . exporting table                BIG_INSERT_EXT2
. . exporting table                      CLOB_TEST
. . exporting table                 CLOB_TEST_EXT2
. . exporting table                           DATA
. . exporting table                       NEW_DATA
. . exporting table                       OLD_DATA
. . exporting table                       PAR_DATA
. . exporting table                    RATED_EVENT
. . exporting table                   SMALL_INSERT
. . exporting table              SMALL_INSERT_EXT2
. . exporting table                              T
. . exporting table                             T1
. . exporting table                             T2
. . exporting table                      TEMP_TEST
. . exporting table                 TEMP_TEST_EXT2
. . exporting table                           TEST
. . exporting table                      TEST_DATA
. . exporting table                 TEST_DATA_EXT2
. . exporting table                      TEST_EXT2
. . exporting table                             TT
. . exporting table                            TTT
. . exporting table                        TT_EXT2
. . exporting table                         T_EXT2
. . exporting table                         T_TEMP
. . exporting table                    T_TEMP_EXT2
. . exporting table                       WIN_LIST
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.
但是很多时候我们都因为是dump文件,感觉一下子没有了方向。无从查起。
如果我们能够得到dump文件中的table列表,那就太好了,我们可以很安全的进行数据的操作。不会稀里糊涂的把一些“未知”操作避免。
如果要解析dump文件,之前分享过一篇日志,通过awk来解析dump文件,得到对应的sql语句,现在来通过一些简单的命令解析dump文件。
我简单测试过百兆,数十G的dump文件,这个命令的速度都还可以,
首先,我们得到一个比较粗略的table list
[ora11g@rac1 dbm_lite]$ strings n1_ddl.dmp|grep "CREATE TABLE"|awk '{print $3}'
"BIG_INSERT"
"CLOB_TEST"
"DATA"
"NEW_DATA"
"OLD_DATA"
"PAR_DATA"
"RATED_EVENT"
"SMALL_INSERT"
"T"
"T1"
"T2"
"TEMP_TEST"
"TEST"
"TEST_DATA"
"TT"
"TTT"
"T_TEMP"
"WIN_LIST"
得到的内容如上所示,我们需要去除双引号,然后加入tables=,每行末尾加入一个逗号。
先去掉双引号
[ora11g@rac1 dbm_lite]$ strings n1_ddl.dmp|grep "CREATE TABLE"|awk '{print $3}'|sed 's/"//g'
BIG_INSERT
CLOB_TEST
DATA
NEW_DATA
OLD_DATA
PAR_DATA
RATED_EVENT
SMALL_INSERT
T
T1
T2
TEMP_TEST
TEST
TEST_DATA
TT
TTT
T_TEMP
WIN_LIST
然后再次判断,如果是第一行就加入前缀tables=,否则加入前缀一个逗号,这样就不用麻烦的判断最后一行的逗号是不是要加了。
[ora11g@rac1 dbm_lite]$  strings n1_ddl.dmp|grep "CREATE TABLE"|awk '{print $3}'|sed 's/"//g'|awk '{ if(FNR==1) print "tables="$1 ; else print ","$1}'
tables=BIG_INSERT
,CLOB_TEST
,DATA
,NEW_DATA
,OLD_DATA
,PAR_DATA
,RATED_EVENT
,SMALL_INSERT
,T
,T1
,T2
,TEMP_TEST
,TEST
,TEST_DATA
,TT
,TTT
,T_TEMP
,WIN_LIST
简单验证一下,可以看到导出的信息很“干净”,我们在数据导入的时候也可以做类似的操作。
[ora11g@rac1 dbm_lite]$ exp n1/n1 file=a.dmp parfile=a.par rows=n statistics=none
Export: Release 11.2.0.3.0 - Production on Tue Aug 26 07:34:19 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses AL32UTF8 character set (possible charset conversion)
Note: table data (rows) will not be exported
About to export specified tables via Conventional Path ...
. . exporting table                     BIG_INSERT
. . exporting table                      CLOB_TEST
. . exporting table                           DATA
. . exporting table                       NEW_DATA
. . exporting table                       OLD_DATA
. . exporting table                       PAR_DATA
. . exporting table                    RATED_EVENT
. . exporting table                   SMALL_INSERT
. . exporting table                              T
. . exporting table                             T1
. . exporting table                             T2
. . exporting table                      TEMP_TEST
. . exporting table                           TEST
. . exporting table                      TEST_DATA
. . exporting table                             TT
. . exporting table                            TTT
. . exporting table                         T_TEMP
. . exporting table                       WIN_LIST
Export terminated successfully without warnings.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23718752/viewspace-1258482/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/23718752/viewspace-1258482/

你可能感兴趣的文章
开源星空照片_如何拍摄星空的好照片
查看>>
usb延长线线序_我应该使用哪种延长线?
查看>>
亚马逊fire充不上电_因此,您只是拥有了Amazon Fire Tablet。 怎么办?
查看>>
如何安装和设置Kuna家用安全摄像机
查看>>
加密机是如何工作的_什么是加密,它如何工作?
查看>>
如何使用Google Assistant控制Xbox One
查看>>
图标缓存 vista_在Windows Vista中将Internet Explorer 7图标添加到桌面
查看>>
iexplore.exe_如何一次杀死所有iexplore.exe进程?
查看>>
discord linux_如何启用和自定义Discord的游戏内叠加
查看>>
ipad 悬浮按钮 自定_如何在iPad上自定义鼠标按钮
查看>>
css 按钮固定在右上交_如何在iPad上交换左右鼠标按钮
查看>>
如何加入“动物杂交:新视野”寻蛋活动
查看>>
cloudlet_使用Search Cloudlet为您的搜索添加种类
查看>>
rsync 同步数据记录_非初学者指南与Rsync同步数据
查看>>
用户名和密码使用的字段类型_如果在“用户名”字段中提交密码,对安全有何影响?...
查看>>
HTG评论RAVPower Bolt:您渴望的多合一充电器
查看>>
firefox pdf预览_如何启用Firefox的内置PDF阅读器
查看>>
android卸载应用代码_如何在Android设备上卸载应用
查看>>
xbmc_如何在XBMC上重新创建频道冲浪体验
查看>>
选择偏好_网站如何记住您的偏好(以及关于Cookie的选择)?
查看>>