Two sequences associated with one identity column

From: "Colin 't Hart" <colinthart(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Two sequences associated with one identity column
Date: 2025-10-29 11:27:44
Message-ID: CAMon-aTbZC5k2pLpijk5x+h__LV08DzpoJtHBgZGkOKJNJ91pw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

One of my clients has a database in which a single identity column
(called "id" in that table) has two sequences associated with it(!)

Both sequences display

Sequence for identity column: <schema>.<table>.id

when described with \d in psql.

Inserting fails with "ERROR: more than one owned sequence found", as
does trying to alter the table to drop the identity on that column.

Trying to drop either sequence results in

ERROR: cannot drop sequence <name> because column id of table <name>
requires it
HINT: You can drop column id of table <name> instead.

while trying to alter either sequence "owned by none" results in

ERROR: cannot change ownership of identity sequence
DETAIL: Sequence "<name>" is linked to table "<name>".

How do we fix this? I presume we need to update the catalog directly
to dissociate one of the sequences and after that drop the orphaned
sequence.

This is in a Postgres 12.22 database that we're trying to upgrade to Postgres 17

Thanks,

Colin

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2025-10-29 12:02:56 Re: Two sequences associated with one identity column
Previous Message Richard Welty 2025-10-28 16:26:01 Re: phadmin4 app not starting after most recent upgrade