From: | Michael Corey <michael(dot)corey(dot)ap(at)nielsen(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Identity and Sequence |
Date: | 2024-02-16 17:23:36 |
Message-ID: | CAABu8T_aAmwcC0d4qKBvqoa0qOgvzsrRHckvg8x_RT2EKqnVdg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
By explicitly making a column an IDENTITY column it is going to make a
sequence behind the scenes even if one with a similar name exists. I tried
and it created part_tab_part_id_seq1. Is there no way to have it use the
original part_tab_part_id_seq? How do I get the data and the sequence in
sync?
On Fri, Feb 16, 2024 at 11:35 AM David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> On Fri, Feb 16, 2024 at 9:24 AM Michael Corey <
> michael(dot)corey(dot)ap(at)nielsen(dot)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.
>
>
--
Michael Corey
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2024-02-16 18:10:23 | Re: Identity and Sequence |
Previous Message | Greg Sabino Mullane | 2024-02-16 17:20:01 | Re: Encryption Options |