如何在PHPMyAdmin中为表设置默认排序(即始终为“主键 - 降序”)

时间:2023-01-25 09:37:47

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.

虽然它在很多方面令人讨厌,但我一直在使用PHPMyAdmin来编写PHP时调试数据库问题。默认情况下,它按主键升序对表进行排序。 99%的时间我宁愿将最新的数据(我的测试数据)显示在默认的顶部,而不是有用的前几个记录。

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

有没有办法配置PHPMyAdmin默认显示最新的记录?改变类似的行为?

6 个解决方案

#1


2  

By default it sorts tables by primary key ascending

默认情况下,它按主键升序对表进行排序

phpMyAdmin isn't performing any sorting at all by default. It's simply asking for all records in a table and MySQL is deciding the order.

默认情况下,phpMyAdmin根本不执行任何排序。它只是要求表中的所有记录,而MySQL正在决定订单。

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

有没有办法配置PHPMyAdmin默认显示最新的记录?改变类似的行为?

There's no way to do this as phpMyAdmin would have to be informed about every primary key of every table (assuming there is one, and only one) and how to sort it.

没有办法做到这一点,因为phpMyAdmin必须被告知每个表的每个主键(假设有一个,只有一个)以及如何对它进行排序。

phpMyAdmin does support bookmarking queries. You could DESC and then bookmark that. However, it certainly won't minimize the number of clicks, if that's what you're aim is.

phpMyAdmin确实支持书签查询。您可以DESC然后将其加入书签。但是,如果这是你的目标,那肯定不会减少点击次数。

http://www.phpmyadmin.net/documentation/

http://www.phpmyadmin.net/documentation/

#2


14  

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:

在phpMyAdmin 4.5.0中,也许在早期版本中,您可以像这样设置$ cfg ['TablePrimaryKeyOrder']配置:

$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’]

当外部没有排序顺序定义时,它定义具有主键的表的默认排序顺序。可接受的值:['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.

如果表具有主键并且未对其应用其他排序,则设置默认排序。

#3


5  

You can save a private bookmark with the name of the table you're browsing.

您可以使用您正在浏览的表的名称保存私人书签。

See https://phpmyadmin.readthedocs.org/en/latest/faq.html#bookmarks-can-i-execute-a-default-bookmark-automatically-when-entering-browse-mode-for-a-table

请参阅https://phpmyadmin.readthedocs.org/en/latest/faq.html#bookmarks-can-i-execute-a-default-bookmark-automatically-when-entering-browse-mode-for-a-table

6.22 Bookmarks: Can I execute a default bookmark automatically when entering Browse mode for a table?

6.22书签:进入表格的浏览模式时,我可以自动执行默认书签吗?

Yes. If a bookmark has the same label as a table name and it’s not a public bookmark, it will be executed.

是。如果书签与表名具有相同的标签,并且它不是公共书签,则将执行该书签。

#4


3  

i think you can do this. Go to a table -> operations and set alter table order by descending. Next time when ever you browse you get the newest row first.

我想你可以做到这一点。转到表 - >操作并通过降序设置alter table顺序。下次您浏览时,首先获得最新的行。

#5


2  

@jeremyclarke, in phpMyAdmin v3.4.5, after login click "home" then, from "More" menu choose "Settings" click "Main frame" tab, then "Browse mode" tab

@jeremyclarke,在phpMyAdmin v3.4.5中,登录后单击“主页”然后,从“更多”菜单中选择“设置”,单击“主框架”选项卡,然后单击“浏览模式”选项卡

There you'll find "Default sorting order" the default mode is set to SMART hence, choose "ASC" or "DESC"

在那里你会发现“默认排序顺序”,默认模式设置为SMART,因此,选择“ASC”或“DESC”

If you do the above steps, it will be saved for the current session,

如果您执行上述步骤,它将保存为当前会话,

to save it permanently set it in config.php http://wiki.phpmyadmin.net/pma/Config#Order

保存它永久设置在config.php http://wiki.phpmyadmin.net/pma/Config#Order

#6


0  

Why don't you use heidi SQL

你为什么不用heidi SQL?

Here's a guide on how:

这是一个如何指导:

Enable login from your host pc.

First of all, get your IP Address - http://www.whatismyip.com Hopefully that's a static IP, otherwise you have some less secure options (below)

首先,获取您的IP地址 - http://www.whatismyip.com希望这是一个静态IP,否则您有一些不太安全的选项(如下)

You'll need access to create a user on the database. You can do this through Cpanel, or in PHP My Admin (assuming you have the right level of access). Google for instructions if you are unsure. Fail that you can attemtp to run this query:

您需要访问权限才能在数据库上创建用户。您可以通过Cpanel或PHP My Admin(假设您具有适当的访问级别)来执行此操作。如果您不确定,可以向Google索取相关说明。您无法运行此查询失败:

CREATE USER 'jason'@'your_ip_here' IDENTIFIED BY 'your_password_here';
GRANT ALL PRIVILEGES ON database_name.* TO 'jason'@'your_ip_here';

If you don't have a static IP Address then you can consider using a wildcard, although this is less secure. Another more secure option is SSH tunneling

如果您没有静态IP地址,则可以考虑使用通配符,尽管这样不太安全。另一个更安全的选择是SSH隧道

Download and install Heidi SQL

http://www.heidisql.com/download.php

http://www.heidisql.com/download.php

Run the install (on windows ofcourse)

运行安装(在windows ofcourse上)

Finally, setup your connection, connect.

最后,设置连接,连接。

You'll find that heidi allows you to easily sort the listing of data, http://www.heidisql.com/screenshots.php?which=data It also remembers sorts and filters too.

您会发现heidi允许您轻松地对数据列表进行排序,http://www.heidisql.com/screenshots.php?which = data它也会记住排序和过滤器。

#1


2  

By default it sorts tables by primary key ascending

默认情况下,它按主键升序对表进行排序

phpMyAdmin isn't performing any sorting at all by default. It's simply asking for all records in a table and MySQL is deciding the order.

默认情况下,phpMyAdmin根本不执行任何排序。它只是要求表中的所有记录,而MySQL正在决定订单。

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

有没有办法配置PHPMyAdmin默认显示最新的记录?改变类似的行为?

There's no way to do this as phpMyAdmin would have to be informed about every primary key of every table (assuming there is one, and only one) and how to sort it.

没有办法做到这一点,因为phpMyAdmin必须被告知每个表的每个主键(假设有一个,只有一个)以及如何对它进行排序。

phpMyAdmin does support bookmarking queries. You could DESC and then bookmark that. However, it certainly won't minimize the number of clicks, if that's what you're aim is.

phpMyAdmin确实支持书签查询。您可以DESC然后将其加入书签。但是,如果这是你的目标,那肯定不会减少点击次数。

http://www.phpmyadmin.net/documentation/

http://www.phpmyadmin.net/documentation/

#2


14  

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:

在phpMyAdmin 4.5.0中,也许在早期版本中,您可以像这样设置$ cfg ['TablePrimaryKeyOrder']配置:

$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’]

当外部没有排序顺序定义时,它定义具有主键的表的默认排序顺序。可接受的值:['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.

如果表具有主键并且未对其应用其他排序,则设置默认排序。

#3


5  

You can save a private bookmark with the name of the table you're browsing.

您可以使用您正在浏览的表的名称保存私人书签。

See https://phpmyadmin.readthedocs.org/en/latest/faq.html#bookmarks-can-i-execute-a-default-bookmark-automatically-when-entering-browse-mode-for-a-table

请参阅https://phpmyadmin.readthedocs.org/en/latest/faq.html#bookmarks-can-i-execute-a-default-bookmark-automatically-when-entering-browse-mode-for-a-table

6.22 Bookmarks: Can I execute a default bookmark automatically when entering Browse mode for a table?

6.22书签:进入表格的浏览模式时,我可以自动执行默认书签吗?

Yes. If a bookmark has the same label as a table name and it’s not a public bookmark, it will be executed.

是。如果书签与表名具有相同的标签,并且它不是公共书签,则将执行该书签。

#4


3  

i think you can do this. Go to a table -> operations and set alter table order by descending. Next time when ever you browse you get the newest row first.

我想你可以做到这一点。转到表 - >操作并通过降序设置alter table顺序。下次您浏览时,首先获得最新的行。

#5


2  

@jeremyclarke, in phpMyAdmin v3.4.5, after login click "home" then, from "More" menu choose "Settings" click "Main frame" tab, then "Browse mode" tab

@jeremyclarke,在phpMyAdmin v3.4.5中,登录后单击“主页”然后,从“更多”菜单中选择“设置”,单击“主框架”选项卡,然后单击“浏览模式”选项卡

There you'll find "Default sorting order" the default mode is set to SMART hence, choose "ASC" or "DESC"

在那里你会发现“默认排序顺序”,默认模式设置为SMART,因此,选择“ASC”或“DESC”

If you do the above steps, it will be saved for the current session,

如果您执行上述步骤,它将保存为当前会话,

to save it permanently set it in config.php http://wiki.phpmyadmin.net/pma/Config#Order

保存它永久设置在config.php http://wiki.phpmyadmin.net/pma/Config#Order

#6


0  

Why don't you use heidi SQL

你为什么不用heidi SQL?

Here's a guide on how:

这是一个如何指导:

Enable login from your host pc.

First of all, get your IP Address - http://www.whatismyip.com Hopefully that's a static IP, otherwise you have some less secure options (below)

首先,获取您的IP地址 - http://www.whatismyip.com希望这是一个静态IP,否则您有一些不太安全的选项(如下)

You'll need access to create a user on the database. You can do this through Cpanel, or in PHP My Admin (assuming you have the right level of access). Google for instructions if you are unsure. Fail that you can attemtp to run this query:

您需要访问权限才能在数据库上创建用户。您可以通过Cpanel或PHP My Admin(假设您具有适当的访问级别)来执行此操作。如果您不确定,可以向Google索取相关说明。您无法运行此查询失败:

CREATE USER 'jason'@'your_ip_here' IDENTIFIED BY 'your_password_here';
GRANT ALL PRIVILEGES ON database_name.* TO 'jason'@'your_ip_here';

If you don't have a static IP Address then you can consider using a wildcard, although this is less secure. Another more secure option is SSH tunneling

如果您没有静态IP地址,则可以考虑使用通配符,尽管这样不太安全。另一个更安全的选择是SSH隧道

Download and install Heidi SQL

http://www.heidisql.com/download.php

http://www.heidisql.com/download.php

Run the install (on windows ofcourse)

运行安装(在windows ofcourse上)

Finally, setup your connection, connect.

最后,设置连接,连接。

You'll find that heidi allows you to easily sort the listing of data, http://www.heidisql.com/screenshots.php?which=data It also remembers sorts and filters too.

您会发现heidi允许您轻松地对数据列表进行排序,http://www.heidisql.com/screenshots.php?which = data它也会记住排序和过滤器。