Answer the question
In order to leave comments, you need to log in
Standard PostgreSQL row sort?
Hello. Tell me, with the "Select * from table" command, PostgreSQL uses its standard sorting of rows (by adding a row). The following question was formed - is this sorting always constant? Or can it change when adding/changing rows? For example, if you change a record in the middle of a table, will it "leave" to the end or remain in the same place?
Answer the question
In order to leave comments, you need to log in
PostgreSQL, like many other DBMSs, stores data in an arbitrary order. And he also selects them randomly, if the sorting rule is not set.
In this case, I recommend creating a separate field in your table (or tables), in which you will record a unique indexed identifier, which must be filled in using the sequence generator (sequence) and also set the default value for the created field with the value from sequence. Then you will sort by this field.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question