Link to home
Start Free TrialLog in
Avatar of Mr_Shaw
Mr_Shaw

asked on

SQL ORDER BY

I have a written a query without putting an ORDER BY.

I noticed that every time I ran the query the order of the records would change.

I have now placed an ORDER BY in the query and the order is now the same every time it is run.

Is it normal for the order to change each time a query is executed if it does not have an ORDER BY?
SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To be precise, the behaviour without ORDER BY is not defined. The DBMS can retrieve records depending on how it gets them: via indexes, materialized views, memory, disk, physical storage and access abilities, aso.
Avatar of Mr_Shaw
Mr_Shaw

ASKER

thanks.