“选择"结果-(按行记录顺序)可能会改变!(不是仅列出行的数据) [英] 'SELECT' result -(record order -by row) may be change !!(not data only listing of row)

查看:155
本文介绍了“选择"结果-(按行记录顺序)可能会改变!(不是仅列出行的数据)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除非您有显式的ORDER BY子句,否则SQL Server环境中没有隐式排序(不存在来自DB的原始顺序").
意思是说,在一个很小的数据库中,例如1 Lak的记录,它不保留插入顺序(即使没有并发插入).
即使在顺序插入期间,它也不会保留顺序.这与MySQL的经验大不相同.

我相信这是真的!

因此,如果我们从数据库中选择详细信息,那么如果我们不使用order by子句,则行顺序可能会发生变化...

例如:从emp中选择*;

Unless you have an explicit ORDER BY clause, there is NO implicit ordering (there is no "original order from DB") in a SQL Server environment.
mean to say, in a small database of say, 1 Lak of records, it does not preserve insertion order (even though there are no concurrent inserts).
Even during sequential inserts, it does not preserve order. This is quite different from MySQL experience.

I beleive it is true!!

So if we are selecting the details from the database, may be the row order will change if we are not using the order by clause...

Ex:select * from emp;

is it correct??

推荐答案

这是我发现的内容:

SELECT是一种面向集合的操作,并且由于集合是无序的,因此除非您明确使用ORDER BY,否则不能保证结果集中的特定顺序.
This is what I found out:

SELECT is a set-oriented operation and, as sets are unordered, no specific order in the resultset is guaranteed, unless you explicitly use ORDER BY.


Order by可能不会更改顺序数据库.是的,它仅用于列出数据.

有关更多信息,请访问:订购依据 [
Order by may not change order in a database. Yes, it''s used only for listing the data.

More at: ORDER BY[^]


这篇关于“选择"结果-(按行记录顺序)可能会改变!(不是仅列出行的数据)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆