Bug #69163 Mysqldump: option for limit and for reverse sorting
Submitted: 7 May 2013 10:39 Modified: 7 May 2013 10:47
Reporter: Marco Gergele Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: mysqldump Command-line Client Severity:S4 (Feature request)
Version:5.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[7 May 2013 10:39] Marco Gergele
mysqldump can sort by primary key, but only ascending.

mysqldump can not limit the number of rows.

I have added two options: 

                      Sorts descending each table's rows by primary key, or
                      first unique key, if such a key exists.  Useful when
                      dumping a MyISAM table to be loaded into an InnoDB table,
                      but will make the dump itself take considerably longer.

--limit[=name]      (numeric!) Number of rows of each table to dump, 0=all

I do need the number for "limit" as a string, so I try to avoid converting it into numbers and back into string.

How to repeat:
mysqldump --order-by-primary sorts ascending, there is no option for descending sort.

Suggested fix:
Patch posted at internals.mysql.com 2013-05-05
[7 May 2013 10:40] Marco Gergele
Patch for mysqldump.c

Attachment: mydump.diff.txt (text/plain), 4.90 KiB.

[7 May 2013 10:47] Sveta Smirnova
Thank you for the reasonable feature request.
[26 Feb 2015 21:45] SIARHEI MM
Can anyone implement this?

It is really good request. Sometimes it is needed to dump database with tables without primary keys. Dump last N records from tables without PK is a good idea.