Re: Serial / auto increment data type - Mailing list pgsql-general

From Scott Marlowe
Subject Re: Serial / auto increment data type
Date
Msg-id 1114635166.13303.1315.camel@state.g2switchworks.com
Whole thread Raw
In response to Serial / auto increment data type  (Typing80wpm@aol.com)
List pgsql-general
On Wed, 2005-04-27 at 15:43, Typing80wpm@aol.com wrote:
> I am just beginning to teach myself Postgresql and Access.  I notice
> that PG has the "serial" type of field which increments
> automatically.   I notice that when I do external links in Access
> through ODBC, that Access wants a field or fields which will be
> unique.
>
> Here is my question.  Would I be wise to define each and ever table
> with a serial id, so that I may always be guaranteed something uniqe,
> to satisfy Access.   It seems to me like no harm can be done, since if
> you dont need the serial id, you dont need it, but it is always there
> if you do need it, and it is harder to add such a field down the line,
> after the fact.

Since 7.4 or 7.3 (I forget which) serial has NOT guaranteed uniqueness.
you have to add unique or primary key to the declaration like so:

create table foo (bar serial unique, otherfield int);

Or replace "unique" with "primary key"...

pgsql-general by date:

Previous
From: "Mak, Jason"
Date:
Subject: Re: populating a table via the COPY command using C code.
Next
From: Sean Davis
Date:
Subject: Re: populating a table via the COPY command using C code.