Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set a default sort for tables in PHPMyAdmin (i.e. always "Primary key - Descending")

Even though its obnoxious in a lot of ways I use PHPMyAdmin all the time to debug database issues while writing PHP. By default it sorts tables by primary key ascending. 99% of the time I would rather have the newest data (my test data) shown at the top by default rather than the useless first few records ever saved.

Is there a way to configure PHPMyAdmin to show the newest records by default? To alter similar behavior?

like image 497
jerclarke Avatar asked Jun 02 '10 16:06

jerclarke


People also ask

How do I sort a table in phpMyAdmin?

In phpMyAdmin go to table structure. On bottom you can press option "Move columns" There you can rearange tables as you see fit. That one is for rearranging columns, not the tables themselves.

Which of the following is the default sorting order in mysql?

The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.


1 Answers

For anyone else who comes here looking for an answer:

In phpMyAdmin 4.5.0, maybe in earlier versions too, you can set the $cfg['TablePrimaryKeyOrder'] config like so:

$cfg['TablePrimaryKeyOrder'] = 'DESC';

This defines the default sort order for the tables, having a primary key, when there is no sort order defines externally. Acceptable values : [‘NONE’, ‘ASC’, ‘DESC’]

This sets the default sort if the table has a primary key and that no other sort has been applied to it.

like image 100
PadraigD Avatar answered Sep 20 '22 06:09

PadraigD