Re: SERIAL type fields

From: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>
To: Andrew Ayers <aayers(at)eldocomp(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SERIAL type fields
Date: 2003-04-24 19:59:34
Message-ID: 3EA84226.A53F2662@nsd.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You should look up ALTER SEQUENCE

Andrew Ayers wrote:
>
> All,
>
> I have been doing a conversion of an Access 97 database to PostgreSQL -
> so far things have been going relatively smoothly. However, I am now
> running into a minor issue - one could almost say it is an asthetic
> issue more than anything.
>
> In the conversion of my Access tables, to a number of them I had to add
> a unique key field. I decided to use a SERIAL type for these fields,
> which set up a "sequence" table (table_field_seq) for each table that
> uses one.
>
> I am now in a process of doing a multiple conversion of data to these
> new tables, where I clear out the table then reload it with new data.
>
> What I came across was that I wanted to reset the sequence number so
> that when the new records were added, they would start at number "1" and
> increase from there.
>
> When you create the table from new, it does this - but after that, the
> sequence table says that the minimum value for the sequence is "1" - and
> not zero - so that when you add records to the table the sequence is
> used on, the first record has a value of "2" in that field when it is added.
>
> I tried to reset the minimum value to "0" - but it wouldn't let me. Does
> anyone know of how you do this, without having to DROP the table and
> sequence, and re-creating them? Is there some kind of ALTER TABLE
> command, or possibly something the database setup, that would allow me
> to alter this behavior?
>
> Thank you for any answers you can provide...
>
> Andrew L. Ayers
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Ayers 2003-04-24 20:02:27 Re: SERIAL type fields
Previous Message David Olbersen 2003-04-24 19:54:16 Re: ODBC & Access [Try 2]