Rows are arranged in random order in the table. Ie there is no guarantee that if I entered the first line in the table, the "first" and then the second line in the "second" ....

Now, when sampling, there is no guarantee what exactly when LIMIT 1 without ORDER_BY will be the first record "first"? In whom practically such situations were or is it just a theory?

The second question is if there is no field when adding a line and not using PRIMARY_KEY how to find out and select data that was previously added?

  • 2
    1. use primary key 2. no primary key or date. - Opalosolo
  • one
    @ ua6xh, and in what way does the primary key solve these problems? Apparently you mean that the primary key must be. int and autoincrement . But, in general, it is not. - avp

1 answer 1

... The primary key can be not only not int, but in general can consist of several fields.
In addition, it is not a theory .
And even if int and auto_increment (which is not changed when inserting or changing), there are no guarantees.
In practice, there was a glitch on Hashcode, when limit was sorted, but in a non-unique field it led to an arbitrary order for select'v sometimes one after another. Let not quite an option from the question, but gives an idea that the sample and the order in it should be specified forcibly.