[GENERAL] Adding identity column to a non-empty table - Mailing list pgsql-general

From Igal @ Lucee.org
Subject [GENERAL] Adding identity column to a non-empty table
Date
Msg-id 37b3858b-0d61-0268-69cc-ff1868ac5255@lucee.org
Whole thread Raw
Responses Re: [GENERAL] Adding identity column to a non-empty table
List 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

pgsql-general by date:

Previous
From: "Igal @ Lucee.org"
Date:
Subject: Re: [GENERAL] Delete Duplicates with Using
Next
From: "Igal @ Lucee.org"
Date:
Subject: Re: [GENERAL] Adding identity column to a non-empty table