Re: sequence id

From: stefan(at)extum(dot)com
To: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: sequence id
Date: 2002-07-17 14:33:17
Message-ID: Pine.LNX.4.44.0207171732480.29565-100000@extum.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Thanks for comment. I am reading about setval() now.

Stefan

On Tue, 16 Jul 2002, Neil Conway wrote:

> On Wed, Jul 17, 2002 at 01:14:10PM +0300, stefan(at)extum(dot)com wrote:
> > my id which is a SERIAL will be incremented ok. But lets say I make
> > mistakes and want to delete from www_server everything. The next id
> > available will be which one was left previously. So If I run the INSERT
> > once I get 1 for my 'id'. If I delete and re-run my INSERT my 'id' is 2.
> >
> > Do I need to do a VACUUM or how to restart from 1 ? I tried VACUUM; but
> > nothing worked. What worked was to DROP SEQUENCE and then the TABLE.
>
> You can use setval() to reset the sequence. In general, sequences are
> not intended to be anything more than unique, sequential numeric
> identifiers -- assuming that there are no "holes" in the sequence or
> that the generated numbers have any meaning in themselves is usually a
> faulty assumption.
>
> > On the other hand is somehow reservated under PostgreSQL the name 'ID' for
> > column ?
> > If I create a table with ID works fine but selects are not working. If I
> > have 'id' for the column I can do SELECTs.
>
> You'll need to enclose it in double-quotes.
>
> Cheers,
>
> Neil
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2002-07-17 14:40:54 Re: table size growing out of control
Previous Message Jan Wieck 2002-07-17 14:31:26 Re: table size growing out of control