D
D
Dannerty2018-10-26 15:53:06
PostgreSQL
Dannerty, 2018-10-26 15:53:06

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

2 answer(s)
S
Sergey Gornostaev, 2018-10-26
@Dannerty

PostgreSQL, like many other DBMSs, stores data in an arbitrary order. And he also selects them randomly, if the sorting rule is not set.

G
Game Master, 2018-11-03
@baitarakhov

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 question

Ask a Question

731 491 924 answers to any question