Re: Auto increment - Mailing list pgsql-novice

From Nabil Sayegh
Subject Re: Auto increment
Date
Msg-id 1054059447.6563.43.camel@billy
Whole thread Raw
In response to Auto increment  ("Fontenot, Paul" <Paul.Fontenot@bannerhealth.com>)
List pgsql-novice
Am Die, 2003-05-27 um 19.37 schrieb Fontenot, Paul:
> When creating a table how do you make an auto incrementing field? I'm
> using:
>
> Create table hosts (
>     id int not null unique primary key,
>     ip char(16),
>     hostname text
> );
>
> Is there a way to make the host.id field automagicaly increment?

id SERIAL PRIMARY KEY

will be translated into int with auto value automatically

P.S.: Primary Keys are automatically not null

HTH
--
 e-Trolley Sayegh & John, Nabil Sayegh
 Tel.: 0700 etrolley /// 0700 38765539
 Fax.: +49 69 8299381-8
 PGP : www.e-trolley.de


pgsql-novice by date:

Previous
From: Rory Campbell-Lange
Date:
Subject: Transaction in function problem
Next
From: Doug Silver
Date:
Subject: Re: Auto increment