473,396 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

mysqldump, entire table in one insert, but multiple lines, how?

I'm aware of the recent mysqldump change, in that it now by default
enables some optimizations.
One of those optimizations is to use single insert statements, instead
of separate insert statements, each on their own lines.
I'm also aware of the --skip-opt / -e / --skip-extended-insert

But what I'd like is a combination of having a single insert statement,
but with each record in its own line, like so:

INSERT INTO `article` (`id`, `title`, `text`) VALUES
(1, 'test', 'this is a test'),
(2, 'test2', 'also a test');

--skip-opt or --skip-extended-insert isn't it, because that'll give me:

INSERT INTO `article` (`id`, `title`, `text`) VALUES (1, 'test', 'this
is a test');
INSERT INTO `article` (`id`, `title`, `text`) VALUES (2, 'test2', 'also
a test');

If this can't be done with mysqldump, does anyone know of an
alternative command-line runnable utility? Thanks in advance!

Aug 5 '05 #1
2 12030
HomerCritic wrote:
But what I'd like is a combination of having a single insert statement,
but with each record in its own line, like so:

INSERT INTO `article` (`id`, `title`, `text`) VALUES
(1, 'test', 'this is a test'),
(2, 'test2', 'also a test');


I also found this was useful, so I piped the output of mysqldump to a
perl command to insert the line breaks. E.g.:

mysqldump <options> | perl -pe 's/\),\(/),\n(/og'

Regards,
Bill K.
Aug 5 '05 #2

Bill Karwin wrote:
HomerCritic wrote:
But what I'd like is a combination of having a single insert statement,
but with each record in its own line, like so:

INSERT INTO `article` (`id`, `title`, `text`) VALUES
(1, 'test', 'this is a test'),
(2, 'test2', 'also a test');


I also found this was useful, so I piped the output of mysqldump to a
perl command to insert the line breaks. E.g.:

mysqldump <options> | perl -pe 's/\),\(/),\n(/og'


Thanks for the feedback. I was hoping that mysqldump could do this
built in, but piping to a script is ok I guess. Your script works,
except if one of the strings contains a ),( it would break it.
Is is possible to enhance the script to detect if it's inside a string?

-Mike-

Aug 6 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware ...
1
by: Tuhin Kumar | last post by:
Hi, I would like to know how to insert multiple rows into a table, using a single INSERT statement. My requirement is like this I have a table ABC which contains multiple employees entries with...
1
by: sqlnewbie | last post by:
I'm a newbie to script writing. I'm trying to write a script to copy all data from a table to the same table in a 2nd database. Both databases are on the same server and are identical in design. ...
12
by: shank | last post by:
I'm trying to use online samples for submitting multiple records from ASP into a stored procedure. Failing! Through the below form, a user could be submitting many records at a time. I'm not...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
3
by: jackson.rayne | last post by:
Hello, Another newbie question here. Let me explain my situation first. I have bought a 3rd party tool that runs a PHP script and gives me some HTML code which I can directly use in my...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.