Will the order of the record retrieved using a select query, be in the same order if retrieved infinite number of times, each time using a new connection? (to the same table, same select)
What order method is used when none is specified?
Will the order of the record retrieved using a select query, be in the same order if retrieved infinite number of times, each time using a new connection? (to the same table, same select)
What order method is used when none is specified?
Depends totally on the query - basically on the way it thinks it will get the query processed fastest.
Which, for all practical means, means the order is "random" (as in: not determined), per standard SQL specifications.
If you do not define an ORDER BY
clause, there's no implied ordering.
It might happen to look like it's being ordered by the primary key or the clustering key - but it's not guaranteed to be that way.
So: if you need a specific order, specify an ORDER BY
.
Will the order of the record retrieved using a select query, be in the same order if retrieved infinite number of times, each time using a new connection?
No. There is no guaranteed "natural" order.
As others have suggested, your results will often be ordered by primary key, but that's not guaranteed, and once you add JOINs there's not even that to go by.