From: | Chris Wilson <chris+google(at)qwirx(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Adding identity column to a non-empty table |
Date: | 2017-12-04 13:24:08 |
Message-ID: | CAOg7f81Zoz663==Upe1_NoyvVoQhpOfEwciDijB2wRKZj+k++g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi all,
I'd like to resurrect this thread, as it seems that there was no definitive
answer:
https://www.postgresql.org/message-id/959f28ef-4245-8349-eff9-0ff5f666df03%40lucee.org
Does anyone know how to add an IDENTITY column to an existing non-empty
table? Like Igal, I get the error message "column "id" contains null
values" when I try to do this:
ALTER TABLE test_table
ADD COLUMN id integer GENERATED ALWAYS AS IDENTITY;
And likewise with GENERATED BY DEFAULT. It seems strange that the column
does not populate itself when set to GENERATED ALWAYS.
From the test cases in src/test/regress/sql/identity.sql
<https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/test/regress/sql/identity.sql;h=e1b5a074c96102f3e1288325ae9a14c3acc90e50;hb=refs/heads/REL_10_STABLE#l19>,
it seems that this is by design, but it seems an unusual design choice to
force the user to jump through hoops to add an IDENTITY column.
Thanks, Chris.
From | Date | Subject | |
---|---|---|---|
Next Message | Melvin Davidson | 2017-12-04 13:55:02 | Re: Problems with triggers and table lock |
Previous Message | Nicola Contu | 2017-12-04 13:19:32 | Centos 6.9 and centos 7 |