码迷,mamicode.com
首页 > 数据库 > 详细

Mysql 内部默认排序

时间:2018-07-08 13:28:34      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:sql   group   ble   wan   默认   stand   something   rom   stack   

mysql默认的排序:

https://forums.mysql.com/read.php?21,239471,239688#msg-239688

 

  • Do not depend on order when ORDER BY is missing.

  • Always specify ORDER BY if you want a particular order -- in some situations the engine can eliminate the ORDER BY because of how it does some other step.

  • GROUP BY forces ORDER BY. (This is a violation of the standard. It can be avoided by using ORDER BY NULL.)

SELECT * FROM tbl -- this will do a "table scan". If the table has never had any DELETEs/REPLACEs/UPDATEs, the records will happen to be in the insertion order, hence what you observed.

If you had done the same statement with an InnoDB table, they would have been delivered in PRIMARY KEY order, not INSERT order. Again, this is an artifact of the underlying implementation, not something to depend on.

 

https://stackoverflow.com/questions/8746519/sql-what-is-the-default-order-by-of-queries

Mysql 内部默认排序

标签:sql   group   ble   wan   默认   stand   something   rom   stack   

原文地址:https://www.cnblogs.com/cbugs/p/9279699.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!