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

Re: Noob question: how to auto-increment index field on INSERT?

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Noob question: how to auto-increment index field on INSERT?
Date: 2009-11-19 19:14:27
Message-ID: he45eh$549$1@ger.gmane.org (view raw or flat)
Thread:
Lists: pgsql-novice
Ken MacDonald wrote on 19.11.2009 19:59:
> Thanks to all who replied so far. I agree that using the serial type 
> would be ideal, and in fact set up a couple test DB's that way. 
> Unfortunately, Django is auto-generating this field from its data 
> models, and I don't seem to have much/any control over its type.
> 
> Looking at pgadmin some more, it appears that column 'id' is set up with 
> a default value of 'nextval('tablename_id_seq'::regclass)'.

Which is essentially what "serial" is: just a shorthand for the above construct

Thomas


In response to

pgsql-novice by date

Next:From: Jasen BettsDate: 2009-11-20 09:46:04
Subject: Re: My second PL/pgSQL function - minor problem
Previous:From: Ken MacDonaldDate: 2009-11-19 18:59:00
Subject: Re: Noob question: how to auto-increment index field on INSERT?

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