SQL行返回顺序 [英] SQL row return order

查看:67
本文介绍了SQL行返回顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到最近每天开始使用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:

  1. 选择表的一部分时,返回的行似乎与选择整个表时出现的顺序相同
  2. 从联接中选择返回的行顺序似乎由联接的最左端成员确定.

这种行为是最常见的数据库(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屋!

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