Re: Auto Increment Questions

From: Jeffrey Melloy <jmelloy(at)visualdistortion(dot)org>
To: Michael Avila <mavila(at)mich(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Auto Increment Questions
Date: 2005-06-16 18:26:49
Message-ID: 42B1C469.3050405@visualdistortion.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jeffrey Melloy 2005-06-16 18:39:48 Re: Library Framework
Previous Message Mace, Richard 2005-06-15 08:35:14 unsubscribe