-
Sequence of rows for SQL with no ORDERBY
Let us say the following query returning 5 rows.
Code:
SELECT USER_ID FROM CLG_USER WHERE USERNAME = 'DEV2FREESTU4'
I tried running this a few times and everytime user_id = 100 is what is being returned first and that was the row last created by the application (we capture something like a create_date). Now, can I say that the row that was last created is the one that will be returned first if there is no ORDERBY in the SQL ?
Thanks.
-
Nope ... the order is essentially random and cannot be relied on.
-
The order is not random, but can change. The only way to guarantee an order is to use an ORDER BY.
Jeff Hunter
-
"essentially random", in thesense that it might as well be, because the point at which the order will change at some future date is not known.
-
I suppose the correct word is "chaotic", since the order is deterministic but in practice unpredictable.
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
-
Wordplay
I think it's safe to say that Jeff's second sentence is the standard Oracle reply,
"The only way to guarantee an order is to use an ORDER BY"
Cheers
Tim...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|