Re: Switching Primary Keys to BigInt

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Mohamed Wael Khobalatte <mkhobalatte(at)grubhub(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Switching Primary Keys to BigInt
Date: 2020-07-21 18:26:09
Message-ID: c996f5f0-6385-20f0-a43d-9915d8d6e5ba@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 7/21/20 11:17 AM, Adrian Klaver wrote:
> On 7/21/20 8:30 AM, Mohamed Wael Khobalatte wrote:
>> Hi all,

> > test_(aklaver)5432> alter table change_seq alter COLUMN id set data type
> bigint;
> ALTER TABLE
> test_(aklaver)5432> \d change_seq
>                             Table "public.change_seq"
>  Column |  Type  | Collation | Nullable |                Default
> --------+--------+-----------+----------+----------------------------------------
>
>  id     | bigint |           | not null |
> nextval('change_seq_id_seq'::regclass)
> Indexes:
>     "change_seq_pkey" PRIMARY KEY, btree (id)

Forgot sequences are bigint by default. It would not hurt to check
pg_sequence just to make sure they are that. In that case the below is
not needed.

>
> test_(aklaver)5432> alter sequence change_seq_id_seq as bigint;
> ALTER SEQUENCE
>
>>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Lewis 2020-07-21 18:43:21 Re: Switching Primary Keys to BigInt
Previous Message Adrian Klaver 2020-07-21 18:17:46 Re: Switching Primary Keys to BigInt