From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Sequences part 2
Date: Tue, 2 Jul 2019 13:02:11 +0200
Message-ID: <bd21060f-c6ce-8c1f-ebe2-e2b594edb60b@gmx.net> (raw)
In-Reply-To: <c5ee3f2d96c4410b88ac9d4492fe1773@UKEXCHMBX003.TechMahindra.com>
References: <c5ee3f2d96c4410b88ac9d4492fe1773@UKEXCHMBX003.TechMahindra.com>
Karl Martin Skoldebrand schrieb am 02.07.2019 um 12:44:
> Looking more at sequences, I have some sequences that start with ID 1, incrementing each record by 1.
>
> So I have e.g. 1 Spain 2. Germany 3. France 4. Ireland 5. Norway
>
> 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.
Why do you think you need that?
A sequence is used to generate a unique number. The only job of that number is to be unique.
You should never rely on PK values to be "gapless" nor should you rely on them defining any kind of ordering.
If you need to sort your countries in a non-default way, add a specific sort_order column to your table which you can use when selecting from the table.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: spam_eater@gmx.net
Subject: Re: Sequences part 2
In-Reply-To: <bd21060f-c6ce-8c1f-ebe2-e2b594edb60b@gmx.net>
References: <c5ee3f2d96c4410b88ac9d4492fe1773@UKEXCHMBX003.TechMahindra.com> <bd21060f-c6ce-8c1f-ebe2-e2b594edb60b@gmx.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox