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

Re: How to make the key in table increase automatically?

From: "Anthony E (dot) Greene" <agreene(at)pobox(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to make the key in table increase automatically?
Date: 2000-08-28 09:41:01
Message-ID: 20000828054101.A18437@cp5340 (view raw or flat)
Thread:
Lists: pgsql-novice
On 24 Aug 2000 14:24 Mathias Göthberg wrote:
>How to make the key in a table increase automatically with 1 every time a
>new row is added?
>
>That is, when I add a new row with all attributes except the primary key,
I
>want the primary key in that row to have a unique number that is 1 higher
>than the previous row.

Use data type 'serial'.

-- 
Anthony E. Greene <agreene(at)pobox(dot)com> <http://www.pobox.com/~agreene/>
PGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26  C484 A42A 60DD 6C94 239D
Linux. The choice of a GNU Generation. <http://www.linux.org/>

In response to

pgsql-novice by date

Next:From: Paula GreveDate: 2000-08-28 13:28:16
Subject: Using a cursor vs. not ?
Previous:From: sujataDate: 2000-08-28 09:27:06
Subject: (no subject)

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