change max_value in sequence

Lists: pgsql-admin
From: "Claus Guttesen" <kometen(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: change max_value in sequence
Date: 2008-09-05 12:58:21
Message-ID: b41c75520809050558o541ac369w2a50fa47a2be2e99@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

Hi.

I have a table with a serial field defined with an older version of
postgresql (ver. 7). Back then max_value was 2147483647:

select max_value from my_bid_seq ;
max_value
------------
2147483647

How can I increase it? By updating the max_value-field? This is an
older thread and may have changed:
http://archives.postgresql.org/pgsql-admin/2002-12/msg00033.php

I'm running postgresql 8.3.1.

--
regards
Claus

When lenity and cruelty play for a kingdom,
the gentler gamester is the soonest winner.

Shakespeare


From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Claus Guttesen" <kometen(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: change max_value in sequence
Date: 2008-09-05 13:52:08
Message-ID: dcc563d10809050652n5a7a8dfdi6b15aad045616d09@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

On Fri, Sep 5, 2008 at 6:58 AM, Claus Guttesen <kometen(at)gmail(dot)com> wrote:
> Hi.
>
> I have a table with a serial field defined with an older version of
> postgresql (ver. 7). Back then max_value was 2147483647:
>
> select max_value from my_bid_seq ;
> max_value
> ------------
> 2147483647
>
> How can I increase it? By updating the max_value-field? This is an
> older thread and may have changed:
> http://archives.postgresql.org/pgsql-admin/2002-12/msg00033.php

That's the max for a regular int / serial type. You'll need to change
it to bigserial / bigint which is 64 bits/

>
> I'm running postgresql 8.3.1.

Please update to 8.3.3


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Claus Guttesen" <kometen(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: change max_value in sequence
Date: 2008-09-05 15:39:10
Message-ID: 24842.1220629150@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin

"Claus Guttesen" <kometen(at)gmail(dot)com> writes:
> I have a table with a serial field defined with an older version of
> postgresql (ver. 7). Back then max_value was 2147483647:
> How can I increase it? By updating the max_value-field?

I think you're looking for ALTER SEQUENCE.

Note that if the column it's feeding into is int4, you'd also need to
alter the column type ...

regards, tom lane