Skip site navigation (1) Skip section navigation (2)

Re: Auto Increment

From: Darrel Davis <darreld(at)davisware(dot)net>
To: Stephen Lawrence <logart(at)dairypower(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Auto Increment
Date: 2000-07-10 17:29:08
Message-ID: Pine.LNX.4.10.10007101325540.11960-100000@camelot (view raw or flat)
Thread:
Lists: pgsql-novice
I'm a Postgres newbie who used MySQL autoincrement functionality
too.  Here's what I found.

If you will create the column type as serial, postgres will
create a sequence and assign the default value for the serial
column to be the sequence.nextval() value.

or you can just create a sequence and upon insertion into the
column, insert the value of the column as sequence.nextval() yourself.

This works for me.  HTH.

-darrel

On Fri, 7 Jul 2000, Stephen Lawrence wrote:

> I am writing a small stamping program and was wondering: what is the best
> way to do auto incrementing. I use MySQL also, and it handles
> auto-incrementing, but postgresql does not.
> 
> I am using the Perl-DBI interface.
> 
> Thanks
> -
> Stephen Lawrence Jr.
> logart(at)dairypower(dot)com
> 
> 


In response to

Responses

pgsql-novice by date

Next:From: vincent.milletDate: 2000-07-10 18:00:49
Subject: oidvector Error with initdb
Previous:From: aliasDate: 2000-07-10 16:42:51
Subject:

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group