gpt4 book ai didi

mysql - SQL : What is the default Order By of queries?

转载 作者:行者123 更新时间:2023-11-29 20:42:37 26 4
gpt4 key购买 nike

未使用 ORDER BY 时查询的默认顺序是什么?

最佳答案

不存在这样的订单。取自http://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.

关于mysql - SQL : What is the default Order By of queries?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38554132/

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