gpt4 book ai didi

mysql - 排序 mySQL 表的字段

转载 作者:搜寻专家 更新时间:2023-10-30 20:13:07 25 4
gpt4 key购买 nike

假设我有一个表格(假设有 50 行,50 列),我偶尔需要对其进行微小的编辑。虽然我意识到我可以(也许你们中的一些人会告诉我我应该)使用查询来执行此操作,但我喜欢使用数据库管理程序(如 Sequel Pro)手动进行更改。

所以我有两个问题:

当您在未指定结果显示顺序的情况下执行查询时,它会遵循它在数据库中的保存顺序。有什么方法可以在不手动切换行的情况下更改该顺序(不是结果的顺序,而是表格本身的顺序)?

还有,有什么方法可以自动对字段在表中的显示方式(列顺序)进行排序吗?

我知道我应该只使用查询来更改值,但是(imo)如果表足够小,我发现在像 Sequel Pro 这样的程序中找到行和列并以这种方式更改它会更容易。

另外,如果我的方法完全错误,请告诉我

最佳答案

http://dev.mysql.com/doc/refman/5.1/en/alter-table.html

ALTER TABLE name ORDER BY something

它带有一些重要的警告,不要依赖它们做任何其他事情,然后可能会通过它进行排序获得一些非常小的性能提升,只是为了方便您在不按以下顺序运行任意选择的工具中使用:

ORDER BY enables you to create the new table with the rows in a specific order. Note that the table does not remain in this order after inserts and deletes. This option is useful primarily when you know that you are mostly to query the rows in a certain order most of the time. By using this option after major changes to the table, you might be able to get higher performance. In some cases, it might make sorting easier for MySQL if the table is in order by the column that you want to order it by later.

关于mysql - 排序 mySQL 表的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3268520/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com