Re: alter existing table column with primary key to auto-increment

From: Rounak Jain <rounakjainis(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: alter existing table column with primary key to auto-increment
Date: 2017-02-18 06:17:43
Message-ID: CANNuxWN4eLxuO10tA60e6ynra8o+Xz1fpNVXySzRhNdE6KpyFw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

yes, thanks for the help, martin.
create sequence product_id_seq;
alter table product alter column id set default nextval('product_id_seq');
alter sequence product_id_seq owned by product.id;

On Fri, Feb 17, 2017 at 9:17 PM, Martin Steer <martinsteer(at)maxi(dot)net(dot)au>
wrote:

> On Sun, Feb 05, 2017 at 04:27:44PM +0530, Rounak Jain wrote:
>
>> alter table customer add column id serial primary key;
>> I want to know how to alter the column instead of dropping it.
>>
>
> Consult the online help:
>
> \h alter
>
> \h alter table
>
> \h alter sequence
>
> M.
>
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message KARIN SUSANNE HILBERT 2017-02-23 01:00:26 Create PostgreSQL Database with ENCODING 'WIN1252' on Cluster Initialized with locale "en_US.UTF-8"?
Previous Message neha khatri 2017-02-14 05:33:59 Re: Regression test : pg_conversion validation