List:General Discussion« Previous MessageNext Message »
From:Mike Johnson Date:May 3 2004 5:49pm
Subject:RE: urban myth?
View as plain text  
From: Boyd E. Hemphill [mailto:bhemphill@stripped]

> My boss says that if you do a select statement against a table the
> result set always comes back in the same order.  I say that this is a
> myth and that the result is random, except when some ordering is
> specified in the SQL statement.
> 
> Who is right?  Is this behavior specified by ANSI or ISO?

From what I understand (as I've heard this explained a half dozen times by different
people), the results are returned in the order they appear on disk. This can change via
any number of factors (such as a disk defrag), though, so you should never rely on
getting results back in the same order every time if you're not using an ORDER BY clause.

For the most part, though, results /will/ appear to come back in the same order. I imagine
that's what your boss is talking about. It's definitely not to be relied on, though.

If this is documented online, I've yet to see it (though I haven't exactly gone looking
for it). Someone else may have a more accurate description of the way it's done, though.


-- 
Mike Johnson
Web Developer
Smarter Living, Inc.
phone (617) 886-5539
Thread
Create table results in (errno: 121)Tom Brown22 Apr
  • Re: Create table results in (errno: 121)Martijn Tonies22 Apr
  • Re: Create table results in (errno: 121)Tom Brown22 Apr
  • Re: Create table results in (errno: 121)Adam28 Apr
    • urban myth?Boyd E. Hemphill3 May
      • Re: urban myth?Peter J Milanese3 May
      • Re: urban myth?Daniel Clark3 May
      • Re: urban myth?Garth Webb3 May
        • Re: urban myth?Bob Ramsey3 May
          • Re: urban myth?Josh Trutwin3 May
          • Re: urban myth?Garth Webb3 May
          • Re: urban myth?Michael Stassen3 May
            • RE: urban myth?Boyd E. Hemphill3 May
              • Re: urban myth?Anders Karlsson3 May
              • Re: urban myth?Michael T. Babcock13 May
      • Re: urban myth?Josh Trutwin3 May
      • Re: urban myth?Jeremy Zawodny3 May
      • Re: urban myth?gerald_clark3 May
        • Re: urban myth?Peter J Milanese3 May
Re: Create table results in (errno: 121)beacker22 Apr
RE: urban myth?Mike Johnson3 May
Re: urban myth?Udikarni3 May