Re: Auto Increment Questions - Mailing list pgsql-novice

From John DeSoi
Subject Re: Auto Increment Questions
Date
Msg-id 77dc08e8d77a32586ce7b912330114b6@pgedit.com
Whole thread Raw
In response to Auto Increment Questions  ("Michael Avila" <mavila@mich.com>)
List pgsql-novice
On Jun 4, 2005, at 2:35 PM, Michael Avila wrote:

> In Postgres I see that it is not so automatic and is not truly
> serial/sequential. Reviewing my objectives, I don't think not being
> truly
> serial/sequential will be a problem.  However, I prefer the automated
> part
> versus my having to code additional lines and hits against the
> database.
>
> Questions:
>
> - Is there ever going to be a truly auto increment feature like MySQL
> has?
> If so, any ideas when?
>
> - What is the easiest, shortest, and safest way to code for serial?
>
> - Are there any pitfalls, gotchas that I need to know about using
> serial?


Serial fields are a suitable replacement for auto increment. All you
need to do is declare your column type to be serial or bigserial. If
you have any concerns about having more rows than the serial or
bigserial can represent, declare the column as unique.




John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Wrong SQLSTATE returned?
Next
From: John DeSoi
Date:
Subject: Re: Data Store on C: