duplicate key value violates unique constraint

From: Ashkar Dev <ashkardev(at)gmail(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: duplicate key value violates unique constraint
Date: 2020-03-07 19:29:51
Message-ID: CAHaowgV2rKK3L30DcjbEy8-L+Pz5qyv8inpsr=y_=qxuXULzLw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

Hi all,

how to fix a problem, suppose there is a table with id and username

if I set the id to bigint so the limit is 9223372036854775807
if I insert for example 3 rows
id username
-- --------------
1 abc
2 def
3 ghi

if I delete all rows and insert one another it is like

id username
-- --------------
4 jkl

So it doesn't start again from non-available id 1, so what is needed to do
to make the new inserts go into non-available id numbers?

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Ashkar Dev 2020-03-07 19:35:03 Fwd: duplicate key value violates unique constraint
Previous Message Scott Ribe 2020-03-06 16:32:55 Re: shm

Browse pgsql-general by date

  From Date Subject
Next Message Ashkar Dev 2020-03-07 19:35:03 Fwd: duplicate key value violates unique constraint
Previous Message Justin 2020-03-07 15:01:03 Re: Rules versus triggers