IMPSHOW2SQL - Extracting SQL from an EXPORT file (Doc ID 29765.1)
Unix Script: IMPSHOW2SQL - Extracting SQL from an EXPORT file (Doc ID 29765.1)
Applies to:
Oracle Database - Enterprise Edition - Version 7.3.4.0 and laterInformation in this document applies to any platform.
***Checked for relevance on 29-Apr-2013***
Purpose
Checked for relevance on 15-APR-2009
This is a short script that allows you to extract the SQL from an export file.
Requirements
It is intended for use on UNIX machines.
Configuring
N/A
Instructions
Instructions are in the header of the script.
When entering the script ensure:
A> The first line in the file should be a single colon (:)
Please note this is a proto-type script so there may be some statements in the resultant file that need manual editting.
Caution
Sample Code
:
# impshow2sql Tries to convert output of an IMP SHOW=Y command into a
# usage SQL script.
#
# To use:
# Start a Unix script session and import with show=Y thus:
#
# $ imp user/password file=exportfile show=Y log=/tmp/showfile
#
# You now have the SHOW=Y output in /tmp/showfile .
# Run this script against this file thus:
#
# $ ./impshow2sql /tmp/showfile > /tmp/imp.sql
#
# The file /tmp/imp.sql should now contain the main SQL for
# the IMPORT.
# You can edit this as required.
# Note: This script may split lines incorrectly for some statements
# so it is best to check the output.
#
# CONSTRAINT "" problem:
# You can use this script to help get the SQL from an export
# then correct it if it includes bad SQL such as CONSTRAINT "".
# Eg:
# Use the steps above to get a SQL script and then
# $ sed -e 's/CONSTRAINT ""//' infile > outfile
# Now precreate all the objects and import the export file.
#
# Extracting Specific Statements only:
# It is fairly easy to change the script to extract certain statements
# only. For statements you do NOT want to extract change N=1 to N=0
# Eg: To extract CREATE TRIGGER statements only:
# a) Change all lines to set N=0.
# Eg: / \"CREATE / { N=0; }
# This stops CREATE statements being output.
#
# b) Add a line (After the general CREATE line above):
# / \"CREATE TRIGGER/ { N=1; }
# This flags that we SHOULD output CREATE TRIGGER statements.
#
# c) Run the script as described to get CREATE TRIGGER statements.
#
awk ' BEGIN { prev=";" }
/ \"CREATE / { N=1; }
/ \"ALTER / { N=1; }
/ \"ANALYZE / { N=1; }
/ \"GRANT / { N=1; }
/ \"COMMENT / { N=1; }
/ \"AUDIT / { N=1; }
N==1 { printf "\n/\n\n"; N++ }
/\"$/ { prev=""
if (N==0) next;
s=index( $0, "\"" );
if ( s!=0 ) {
printf "%s",substr( $0,s+1,length( substr($0,s+1))-1 )
prev=substr($0,length($0)-1,1 );
}
if (length($0)<78) printf( "\n" );
}' $*
Sample Output
No sample output provided.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17252115/viewspace-1083944/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Export/import Datas To/from a Csv FileExportImport
- Extracting DDLs from OracleOracle
- TECH: Getting a Stack Trace from a CORE file on Unix (Doc ID 1812.1)
- Recipe 6.7. Extracting Initials from a Name
- Master Note For PL/SQL UTL_FILE Package (Doc ID 1155024.1)ASTSQLPackage
- No Response from the Server, Does it Hang or Spin? (Doc ID 68738.1)Server
- Export data from a data blockExportBloC
- RMAN Restore Performance from Tape is Very Poor (Doc ID 850988.1)RESTORM
- How to free space from an ASM diskgroup? (Doc ID 1553744.1)ASM
- IMP-00010: not a valid export file tipsExport
- Script: To remove Chained Rows from a Table (Doc ID 1019556.6)REMAI
- The Best Way to Export an SVG from SketchExportSVG
- OAF export data from VO in xlsx formatExportORM
- Export with Spool and Parallel Utl_FileExportParallel
- IMP-00009: abnormal end of export fileORMExport
- export ORACLE_SID=founder exportExportOracle
- How To Replicate Data from Oracle to Postgres Using GoldenGate (Doc ID 1544137.1OracleGo
- Removing a Node from a 10gR1 RAC Cluster (Doc ID 269320.1)REM
- Move datafile:From File System to ASMASM
- Move datafile:From ASM to File SystemASM
- It is indirectly referenced from required .class fileUI
- Restore Controlfile from SBT Tape Fails RMAN-6172 (Doc ID 1314134.1)RESTAI
- Extracting Data from a Corrupt Table using DBMS_REPAIR or Event 10231AI
- File list Export for Mac(檔案列表匯出工具)ExportMac
- File list Export for Mac檔案列表匯出工具ExportMac
- 從Export Dumpfile file 中讀出DDL 語句Export
- oracle sql hint提示_BITMAP CONVERSION FROM ROWIDSOracleSQL
- 用PHP轉DOC ms word file to HTML 的方法PHPHTML
- Unreal: Dynamic load map from Pak fileUnreal
- Catalog archivelog from file system to Asmdg;HiveASM
- Unload data to a flat file from Oracle databaseOracleDatabase
- Script to Collect DRM Information (drmdiag.sql) (Doc ID 1492990.1)ORMSQL
- ImportError: cannot import name 'get_ora_doc' from partially initialized moduleImportErrorZed
- SQL on file 工具SQL
- 高手sos!!! Unable to load document from file...
- /usr/share/mysql/czech/errmsg.sys from *** conflicts with file from package **MySqlPackage
- 修改vip (Doc ID 276434.1)
- How to copy a datafile from ASM to a file system not using RMANASM