Re: SERIAL type fields - Mailing list pgsql-general

From Jean-Luc Lachance
Subject Re: SERIAL type fields
Date
Msg-id 3EA84226.A53F2662@nsd.ca
Whole thread Raw
In response to Re: SERIAL type fields  (Andrew Ayers <aayers@eldocomp.com>)
List 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


pgsql-general by date:

Previous
From: "David Olbersen"
Date:
Subject: Re: ODBC & Access [Try 2]
Next
From: Darren Ferguson
Date:
Subject: Re: pl-pgsql question