Re: Auto Increment Questions - Mailing list pgsql-novice

From Jeffrey Melloy
Subject Re: Auto Increment Questions
Date
Msg-id 42B1C469.3050405@visualdistortion.org
Whole thread Raw
In response to Auto Increment Questions  ("Michael Avila" <mavila@mich.com>)
List pgsql-novice
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.
>
Are you saying that since serial isn't guaranteed to be 1,2,3,4,5
without gaps there will be a problem?

You can't just do something like "select max(val) + 1 from table" to get
the next serial value.  You need to do "select nextval(sequence)" and
then use "currval(sequence)" to get the current value.

If you don't care what the inserted value is, just use the DEFAULT
keyword in your inserts.

More information can be found in the manual.

Jeff

pgsql-novice by date:

Previous
From: "Mace, Richard"
Date:
Subject: unsubscribe
Next
From: Jeffrey Melloy
Date:
Subject: Re: Library Framework