SQL行返回顺序 [英] SQL row return order
问题描述
直到最近每天开始使用SQL时,我才很少使用SQL.我注意到,如果不使用"order by"子句:
I have only used SQL rarely until recently when I began using it daily. I notice that if no "order by" clause is used:
- 选择表的一部分时,返回的行似乎与选择整个表时出现的顺序相同
- 从联接中选择返回的行顺序似乎由联接的最左端成员确定.
这种行为是最常见的数据库(MySql,Oracle,PostgreSQL,Sqlite,Sql Server)中可以依靠的一种标准东西吗? (我什至不知道是否真的可以在sqlite中依靠它).如果这样的话,它的严格程度如何?(例如,如果一个人使用分组依据",那么各个分组都将具有该顺序)?
Is this behaviour a standard thing one can count on in the most common databases (MySql, Oracle, PostgreSQL, Sqlite, Sql Server)? (I don't really even know whether one can truly count on it in sqlite). How strictly is it honored if so (e.g. if one uses "group by" would the individual groups each have that ordering)?
推荐答案
第20.2节<直接选择语句:多行> ;, SQL-92规范:
Section 20.2 <direct select statement: multiple rows>, subsection "General Rules" of the SQL-92 specification:
4) If an <order by clause> is not specified, then the ordering of
the rows of Q is implementation-dependent.
这篇关于SQL行返回顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!