'Retrieving rows in physical order [duplicate]
Let's say I have a table that has the following data inserted in order:
name age
tom 20
sarah 30
Is there a way to retrieve the rows that orders it by its 'default ordering' (usually physical location on disk/memory)? Two examples might be:
SELECT * FROM tbl -- guarantee it's ordered properly either implicitly or explicitly
SELECT LAG OVER (ORDER BY ...?) FROM tbl
I know this is not a strictly ASNI SQL topic as the rows are not ordered when defined mathematically, but I'm looking to see if it's possible to implement this in actuality.
Solution 1:[1]
Since there can be no logical sort wthout using ORDER BY the physical order would be effectively invisible. The order of rows returned by a SELECT statement is undefined unless you use ORDER BY.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nick M |
