Re: SERIAL type fields

From: Andrew Ayers <aayers(at)eldocomp(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SERIAL type fields
Date: 2003-04-24 19:43:24
Message-ID: 3EA83E5C.7090308@eldocomp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message scott.marlowe 2003-04-24 19:46:04 Re: SERIAL type fields
Previous Message Dennis Gearon 2003-04-24 19:37:31 Re: ODBC & Access [Try 2]