MySQL中的默认排序(ALTER TABLE ... ORDER BY ...;) [英] Default sort-ordering in MySQL (ALTER TABLE ... ORDER BY ...;)
本文介绍了MySQL中的默认排序(ALTER TABLE ... ORDER BY ...;)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假定通过执行以下操作来更改MySQL表(ISAM)的默认顺序:
Assume that the default ordering of a MySQL-table (ISAM) is changed by executing:
ALTER TABLE tablename ORDER BY columnname ASC;
从现在开始,我保证以假设我的查询中未指定"ORDER BY"的方式按列名ASC"的顺序获取从表中检索到的记录.在哪里...限制10;)?
From now on, am I guaranteed to obtain records retrieved from the table in the order of "columnname ASC" assuming no "ORDER BY" is specified in my queries (i.e. "SELECT * FROM tablename WHERE ... LIMIT 10;")?
我应该注意什么极端情况吗?
Are there any corner-cases that I should be aware of?
更新#1:非常感谢Quassnoi正确地指出INSERT和DELETE弄乱了顺序.这使我想到以下额外的问题:
Update #1: Thanks a lot to Quassnoi who correctly pointed out that INSERTs and DELETEs messes up the ordering. This leads me to the following to extra questions:
- 那UPDATEs又如何呢?假设没有对表进行INSERT或DELETE操作,而仅对更新进行了操作-排序顺序会保持不变吗?
- 假设已完成INSERT和DELETE-如何再次重建"排序,每天说一次(在这种情况下,表格每天仅更改一次,因此在完成更改后每天重新生成表格应该还是可以的! ). REPAIR TABLE是否可以修复它,还是必须再次添加ALTER TABLE ... ORDER BY?
推荐答案
查看全文