透過shell解析dump生成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/30633755/viewspace-2127769/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 通過shell解析dump生成parfile
- 透過shell指令碼定位效能sql和生成報告指令碼SQL
- 透過shell指令碼生成查詢表資料的sql指令碼SQL
- 透過shell指令碼生成資料統計資訊的報表指令碼
- 透過shell抓取html資料HTML
- 透過shell指令碼分析足彩指令碼
- 使用 ssmtp 於 shell 透過 Gmail 寄信SSMAI
- 透過shell定製ash指令碼指令碼
- 透過shell指令碼檢視鎖資訊指令碼
- 透過shell指令碼監控oracle session指令碼OracleSession
- 高通進dump和抓取解析dump log
- 透過shell指令碼檢視procedure的資訊指令碼
- 透過shell指令碼檢視package的資訊指令碼Package
- 一次透過dump檔案分析OutOfMemoryError異常程式碼定位過程Error
- JPA透過表反向生成相關類
- 透過shell和sql結合查詢效能sqlSQL
- 透過shell指令碼得到資料字典的資訊指令碼
- [Shell] Shell 生成 HTML指令碼HTML指令碼
- Linux透過Shell命令向埠傳送資料Linux
- 透過shell分析表依賴的層級關係
- 透過shell定製dbms_advisor.quick_tuneUI
- 海量資料遷移之透過shell估算資料量
- 透過shell指令碼監控sql執行頻率指令碼SQL
- 如何透過SqlResultSetMapping和NamedNativeQuery生成DTO?SQLAPP
- 如何透過建構函式和JPQL生成DTO?函式
- 透過shell指令碼監控日誌切換頻率指令碼
- shell指令碼-透過lftp同步遠端目錄到本地指令碼FTP
- 透過shell來比較oracle和java中的字串使用OracleJava字串
- 通過shell指令碼定位效能sql和生成報告指令碼SQL
- 詳解Dart中如何透過註解生成程式碼Dart
- 如何透過javax.persistence.Tuple和原生SQL生成DTO?JavaSQL
- 如何透過ResultTransformer和原生SQL或JPQL生成DTO?ORMSQL
- 使用awk來解析dump檔案
- 透過shell得到資料庫中許可權的指令碼資料庫指令碼
- 透過shell指令碼抓取awr報告中的問題sql指令碼SQL
- 通過shell指令碼生成查詢表資料的sql指令碼SQL
- PHP Shell生成工具WeevelyPHP
- netbeans透過wsdl生成webservice的UTF8問題BeanWeb