Re: Identity and Sequence - Mailing list pgsql-general

From David G. Johnston
Subject Re: Identity and Sequence
Date
Msg-id CAKFQuwZGyW+Gn1_Wa6e5=NtTpsnmVgH=6JV516M8r+J4rjyVHQ@mail.gmail.com
Whole thread Raw
In response to Identity and Sequence  (Michael Corey <michael.corey.ap@nielsen.com>)
Responses Re: Identity and Sequence
List pgsql-general
On Fri, Feb 16, 2024 at 9:24 AM Michael Corey <michael.corey.ap@nielsen.com> wrote:
If I run these two statements I get an error
ERROR:  relation "part_tab_part_id_seq" already exists

I tried different combinations of this ALTER TABLE statement and none seem to work.  What is the proper way to reattach the identity and the sequence bearing in mind that I will load the new table with the data from the old table?


So remove the generated by default from the old non-partitioned table (manually drop the sequence if needed too'.  Or just choose a different sequence name for the new one.

"reattach the identity" isn't a thing - the system is telling you it is creating a new one and you will need to synchronize it to your data.

David J.

pgsql-general by date:

Previous
From: Michael Corey
Date:
Subject: Identity and Sequence
Next
From: Greg Sabino Mullane
Date:
Subject: Re: Encryption Options