Happy medium for extended inserts

This is a discussion on Happy medium for extended inserts within the MySQL Database forums, part of the Database Forums category; The default for mysqldump is to enable --opt, which in turn enables --extended-insert. This results in a smaller dump ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-28-2007
Jorey Bump
 
Posts: n/a
Default Happy medium for extended inserts

The default for mysqldump is to enable --opt, which in turn enables
--extended-insert. This results in a smaller dump file that is faster to
reload. However, it's extremely difficult to view a large dump in a text
editor. Disabling the feature with --skip-extended-insert creates
individual INSERT statements for each record, producing a larger file that
is slower to reload. Is there any way to keep --extended-insert, but have
each record dumped on a single line?

I'm thinking of something like this:

INSERT INTO `foo` VALUES
('1', 'Doe', 'John'),
('2', 'Doe', 'Jane');

instead the default:

INSERT INTO `foo` VALUES ('1', 'Doe', 'John'),('2', 'Doe', 'Jane');

Reply With Quote
  #2 (permalink)  
Old 01-30-2007
Kees Nuyt
 
Posts: n/a
Default Re: Happy medium for extended inserts

On Sun, 28 Jan 2007 16:32:55 -0500, Jorey Bump
<devnull@joreybump.com> wrote:

>The default for mysqldump is to enable --opt, which in turn enables
>--extended-insert. This results in a smaller dump file that is faster to
>reload. However, it's extremely difficult to view a large dump in a text
>editor. Disabling the feature with --skip-extended-insert creates
>individual INSERT statements for each record, producing a larger file that
>is slower to reload. Is there any way to keep --extended-insert, but have
>each record dumped on a single line?
>
>I'm thinking of something like this:
>
>INSERT INTO `foo` VALUES
>('1', 'Doe', 'John'),
>('2', 'Doe', 'Jane');
>
>instead the default:
>
>INSERT INTO `foo` VALUES ('1', 'Doe', 'John'),('2', 'Doe', 'Jane');


Pipe it through sed replacing "),(" by "),newline("
--
( Kees
)
c[_] You don't win wars by dying for your country. You win
by making the other poor bastard die for his country. (#226)
Reply With Quote
  #3 (permalink)  
Old 02-01-2007
Jorey Bump
 
Posts: n/a
Default Re: Happy medium for extended inserts

On Wed, 31 Jan 2007 00:02:28 +0100, Kees Nuyt wrote:

> Pipe it through sed replacing "),(" by "),newline("


Thanks! Works great:

mysqldump -u bob -p foo | sed "s/),(/),\n(/g" > foo.sql
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:52 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0