dbTalk Databases Forums  

Omit auto-increment values using mysqldump

comp.databases.mysql comp.databases.mysql


Discuss Omit auto-increment values using mysqldump in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Endel Dreyer
 
Posts: n/a

Default Omit auto-increment values using mysqldump - 06-26-2011 , 12:49 PM






Hey there,

I've just found a tip for omiting auto-increment column values using
mysqldump:
mysqldump -u root -pYourPasword database table_name --compact --no-
create-info | sed -r "s/\([0-9]*/\(NULL/g"

More details on my blog:
http://bugfixer.endel.me/2011/06/25/...ing-mysqldump/

Hope it be useful for someone else.

Reply With Quote
  #2  
Old   
Luuk
 
Posts: n/a

Default Re: Omit auto-increment values using mysqldump - 06-26-2011 , 01:04 PM






On 26-06-2011 19:49, Endel Dreyer wrote:
Quote:
Hey there,

I've just found a tip for omiting auto-increment column values using
mysqldump:
mysqldump -u root -pYourPasword database table_name --compact --no-
create-info | sed -r "s/\([0-9]*/\(NULL/g"

More details on my blog:
http://bugfixer.endel.me/2011/06/25/...ing-mysqldump/

Hope it be useful for someone else.
This only works if your auto-increment column is the first column in
your table

--
Luuk

Reply With Quote
  #3  
Old   
Jerry Stuckle
 
Posts: n/a

Default Re: Omit auto-increment values using mysqldump - 06-26-2011 , 01:27 PM



On 6/26/2011 1:49 PM, Endel Dreyer wrote:
Quote:
Hey there,

I've just found a tip for omiting auto-increment column values using
mysqldump:
mysqldump -u root -pYourPasword database table_name --compact --no-
create-info | sed -r "s/\([0-9]*/\(NULL/g"

More details on my blog:
http://iamaspammer.com

Hope it be useful for someone else.
And a very dangerous thing to do - especially if you have foreign keys
depending on the auto-increment column's value, which is quite common in
relational databases. If you ever have to restore the database, you'll
end up with rows in one table mismatched with rows in another table.

But then we all know your real reason for posting this "hint".

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex (AT) attglobal (DOT) net
==================

Reply With Quote
  #4  
Old   
onedbguru
 
Posts: n/a

Default Re: How to hose your database - 06-29-2011 , 09:17 PM



On Jun 26, 1:49*pm, Endel Dreyer <endel.dre... (AT) gmail (DOT) com> wrote:
Quote:
Hey there,

I've just found a tip for omiting auto-increment column values using
mysqldump:
mysqldump -u root -pYourPasword database table_name --compact --no-
create-info | sed -r "s/\([0-9]*/\(NULL/g"

More details on my blog <REDACTED to prevent propagating crap like this

Hope it be useful for someone else.
Title should be: "How to hose your database".

As has been stated, this is very dangerous thing to do or even
suggest. Most script-kiddies that read these posts do not know how
dangerous it could be. One would be very foolish to follow this advice.

Reply With Quote
  #5  
Old   
J.O. Aho
 
Posts: n/a

Default Re: Omit auto-increment values using mysqldump - 07-01-2011 , 01:50 AM



On Sun, 26 Jun 2011, Endel Dreyer wrote:

Quote:
Hey there,

I've just found a tip for omiting auto-increment column values using
mysqldump:
mysqldump -u root -pYourPasword database table_name --compact --no-
create-info | sed -r "s/\([0-9]*/\(NULL/g"

Hope it be useful for someone else.
This will not be helpful for anyone at all, the regexp is flawed and even
if the obvious flaw was fixed, you would replace all ( and the following
numbers if any with (NULL.

As others mentioned you may ruin dependencies between tables with this if
it had worked as you thought, and renumbering primary keys where they may
be foreign key dependencies can lead to that you will not have all the data
in the database.

Before posting, please check what you post really does work, there will be
people who may think it works and ruins their database... but maybe that
was your intention.


--
//Aho

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 On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.