Adding identity column to a non-empty table

From: "Igal (at) Lucee(dot)org" <igal(at)lucee(dot)org>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Adding identity column to a non-empty table
Date: 2017-10-15 23:01:40
Message-ID: 37b3858b-0d61-0268-69cc-ff1868ac5255@lucee.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I'm trying to add an identity column to a table that has records
(previously had a bigserial column which I removed):

  ALTER TABLE event_log
ADD COLUMN r_id BIGINT GENERATED BY DEFAULT AS IDENTITY;

But I'm getting an error `column r_id contains null values`.

How can I add the column and populate it for the existing rows?

Thanks,

Igal Sapir
Lucee Core Developer
Lucee.org <http://lucee.org/>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Igal @ Lucee.org 2017-10-16 00:24:37 Re: Adding identity column to a non-empty table
Previous Message Igal @ Lucee.org 2017-10-15 19:28:36 Re: Delete Duplicates with Using