3
Suppose I have a table called "student" in the database, and its columns are nome
, matricula
and curso
, your primary key being the column matricula
. The column matricula
does not have auto_increment and a larger registration number does not necessarily mean that it was entered after a smaller registration number. Example: registration number 201033 was inserted after 201941. If I turn the remote:
SELECT * FROM aluno;
I know all records are returned, but the first row returned is the row that was inserted first and the last returned is the last that was inserted? What is the default order of the query result? In this specific case, it would be possible to order the query by insertion order, since I do not have a field in the table that represents the order in which the lines (tuples) were inserted?
"will appear in the physical order of the table" This is not certain, it will depend on Quey’s optimizer. If you optimize to choose some index to execute the query, this index can change the order of the result, which may not be the "physical order". Since it was punctuated in the other answer, we can say that the order is "undetermined"
– Ricardo Pontual
Yes, yes, and it can also come in the order it’s in the cache.
– user178974
I edited the answer.
– user178974