<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.6.5" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: How Do You Edit a dump/exp/script  File?</title>
	<link>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file</link>
	<description>News and views from Pythian DBAs</description>
	<pubDate>Thu,  4 Dec 2008 23:48:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
		<item>
		<title>By: Log Buffer #109: A Carnival of the Vanities for DBAs</title>
		<link>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file#comment-254250</link>
		<dc:creator>Log Buffer #109: A Carnival of the Vanities for DBAs</dc:creator>
		<pubDate>Fri, 08 Aug 2008 17:23:00 +0000</pubDate>
		<guid>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file#comment-254250</guid>
		<description>[...] Rusty Razor Blade&#8217;s Jon Haddad has a quick tip on executing MySQL queries within Vim. Along the same lines, Pythian&#8217;s Keith Murphy and his readers offer different ways to edit a dump/exp/script file. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Rusty Razor Blade&#8217;s Jon Haddad has a quick tip on executing MySQL queries within Vim. Along the same lines, Pythian&#8217;s Keith Murphy and his readers offer different ways to edit a dump/exp/script file. [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LenZ</title>
		<link>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file#comment-253549</link>
		<dc:creator>LenZ</dc:creator>
		<pubDate>Thu, 07 Aug 2008 10:14:24 +0000</pubDate>
		<guid>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file#comment-253549</guid>
		<description>The MySQL distribution actually ships with a small commandline tool that does exactly that - take a look at the "replace" command. I blogged about it some time ago:

http://www.lenzg.org/archives/149-A-hidden-gem-in-the-MySQL-distribution-replace.html

So in your case, you could do the following:

$ replace "INSERT" "INSERT REPLACE" -- file.sql</description>
		<content:encoded><![CDATA[<p>The MySQL distribution actually ships with a small commandline tool that does exactly that - take a look at the &#8220;replace&#8221; command. I blogged about it some time ago:</p>
<p><a href="http://www.lenzg.org/archives/149-A-hidden-gem-in-the-MySQL-distribution-replace.html" rel="nofollow">http://www.lenzg.org/archives/149-A-hidden-gem-in-the-MySQL-distribution-replace.html</a></p>
<p>So in your case, you could do the following:</p>
<p>$ replace &#8220;INSERT&#8221; &#8220;INSERT REPLACE&#8221; &#8212; file.sql</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sheeri Cabral</title>
		<link>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file#comment-252781</link>
		<dc:creator>Sheeri Cabral</dc:creator>
		<pubDate>Wed, 06 Aug 2008 11:52:50 +0000</pubDate>
		<guid>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file#comment-252781</guid>
		<description>Gregory -- check your mysqldump options, you can stop mysqldump from throwing in "use databasename".</description>
		<content:encoded><![CDATA[<p>Gregory &#8212; check your mysqldump options, you can stop mysqldump from throwing in &#8220;use databasename&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sheeri Cabral</title>
		<link>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file#comment-252779</link>
		<dc:creator>Sheeri Cabral</dc:creator>
		<pubDate>Wed, 06 Aug 2008 11:52:15 +0000</pubDate>
		<guid>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file#comment-252779</guid>
		<description>The great thing about sed being a stream editor is that you can pipe the output of mysqldump directly into sed and then save the file....

so instead of 

mysqldump &gt; file.sql
you can do
mysqldump &#124; sed 's/^INSERT/REPLACE/' &gt; file.sql

(^ represents the beginning of the line, and I didn't put the global switch "g".  Without "g" it will only replace the first instance per line, which is fine in this particular example...and yeah, people should definitely read the sed manual!)</description>
		<content:encoded><![CDATA[<p>The great thing about sed being a stream editor is that you can pipe the output of mysqldump directly into sed and then save the file&#8230;.</p>
<p>so instead of </p>
<p>mysqldump > file.sql<br />
you can do<br />
mysqldump | sed &#8217;s/^INSERT/REPLACE/&#8217; > file.sql</p>
<p>(^ represents the beginning of the line, and I didn&#8217;t put the global switch &#8220;g&#8221;.  Without &#8220;g&#8221; it will only replace the first instance per line, which is fine in this particular example&#8230;and yeah, people should definitely read the sed manual!)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gregory Haase</title>
		<link>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file#comment-252186</link>
		<dc:creator>Gregory Haase</dc:creator>
		<pubDate>Tue, 05 Aug 2008 19:18:51 +0000</pubDate>
		<guid>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file#comment-252186</guid>
		<description>In general, you have to be careful opening dumpfiles in editors of any kind. You can easily run into issues where special characters or binary data gets mangled. Strictly speaking, these are NOT ASCII text files.

For most cases, there are command line switches to mysqldump (e.g. --replace) that can be used to get the data in the format you want.

Another trick is to make two passes at mysqldump - the first one grabbing structure only (--no-data --routines --events), and the second one with --no-create-info. You can safely edit the first file even if you have blobs in your data model.

But the problem I run into most often is that the dump file contains "USE DATABASENAME" at the head, and if you don't remove it, you could end up accidentally restoring your database to an old copy.</description>
		<content:encoded><![CDATA[<p>In general, you have to be careful opening dumpfiles in editors of any kind. You can easily run into issues where special characters or binary data gets mangled. Strictly speaking, these are NOT ASCII text files.</p>
<p>For most cases, there are command line switches to mysqldump (e.g. &#8211;replace) that can be used to get the data in the format you want.</p>
<p>Another trick is to make two passes at mysqldump - the first one grabbing structure only (&#8211;no-data &#8211;routines &#8211;events), and the second one with &#8211;no-create-info. You can safely edit the first file even if you have blobs in your data model.</p>
<p>But the problem I run into most often is that the dump file contains &#8220;USE DATABASENAME&#8221; at the head, and if you don&#8217;t remove it, you could end up accidentally restoring your database to an old copy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giuseppe Maxia</title>
		<link>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file#comment-252182</link>
		<dc:creator>Giuseppe Maxia</dc:creator>
		<pubDate>Tue, 05 Aug 2008 19:16:36 +0000</pubDate>
		<guid>http://www.pythian.com/blogs/1150/how-do-you-edit-a-dump-exp-script-file#comment-252182</guid>
		<description>Hi Keith!
sed?
what about Perl?

http://datacharmer.blogspot.com/2008/08/editing-dump-file-from-airport.html

Cheers

Giuseppe</description>
		<content:encoded><![CDATA[<p>Hi Keith!<br />
sed?<br />
what about Perl?</p>
<p><a href="http://datacharmer.blogspot.com/2008/08/editing-dump-file-from-airport.html" rel="nofollow">http://datacharmer.blogspot.com/2008/08/editing-dump-file-from-airport.html</a></p>
<p>Cheers</p>
<p>Giuseppe</p>
]]></content:encoded>
	</item>
</channel>
</rss>
