Re: Sequences part 2 - Mailing list pgsql-general

From Thomas Kellerer
Subject Re: Sequences part 2
Date
Msg-id 718af8b0-d6e9-a059-9cc8-4806d3466e13@gmx.net
Whole thread Raw
In response to RE: Sequences part 2  (Karl Martin Skoldebrand <KS0C77263@TechMahindra.com>)
List pgsql-general
Karl Martin Skoldebrand schrieb am 02.07.2019 um 13:20:
>>> Now I want to insert more countries, between France and Ireland.
>> 
>> That is a wrong assumption - there is no "between" for rows in a
>> relational database.
>> 
> 
> Yes, I'm fairly aware of this. However the application the 
> database table belongs to seems to rely on a specific order in the 
> database. I.e. if I just add value to the table they end up, possibly
> due to how the application is coded in an undesireable spot on the
> web page. That is why I wanted them to be inserted with the previous
> records.
There is no "order of rows" in a relational database. 

Even _if_ you squeeze the IDs of the new rows between existing ones, 
you still have no guarantee whatsoever on the order of the rows 
returned by a SELECT statement. 

The only(!) way to get a guaranteed sort order is to use ORDER BY. 

Thomas



pgsql-general by date:

Previous
From: Karl Martin Skoldebrand
Date:
Subject: RE: Sequences part 2
Next
From: Ron
Date:
Subject: Re: Statistics tables not being updated anymore