A SELECT statement without an ORDER BY clause return some rows.
Which statement is always true about the order of the returned results?
A.
The results are in ascending order.
B.
The results are in descending order.
C.
The results are in the order inserted.
D.
The results are not in a set order.
Explanation:
Reference:
http://www.postgresql.org/docs/8.2/static/sql-select.html#SQL-ORDERBY
C.
D:The results are not in a set order.
It is impacted by index ,
if there is index ,it will return a ascending order ,
if there is not any index ,it will return the order inserted .
Looks like D. Another tricky question.
From MySQL 5.0 Certification Study Guide by Dubois, Hinz, and Pedersen:
“By default, the rows in the result set produced by a SELECT statement are returned by the server to the client in no particular order. When you issue a query, the server is free to return the rows in any convenient order. This order can be affected by factors such as the order in which rows are actually stored in the table or which indexes are used to process the query.”
D
I have tested.
D i just tested
C
It’s D. For example if you have table with col1 that has values 1,4,2,3 and its indexed as PRIMARY KEY the result will be returned in ASCENDING order, but if you have col2 that has same values like col1 but its not indexed as primary key, the result will be in the order inserted.
So it’s D.
Btw I dont know if this is only for primary key. I only tested this with primary key.