Re: Create unique field..

From: Nabil Sayegh <imap(at)sayegh(dot)de>
To: "Williams," Travis "L," NPONS <tlw(at)att(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Create unique field..
Date: 2001-06-07 20:14:46
Message-ID: 991944886.2619.0.camel@billy.labor.localnet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 07 Jun 2001 14:58:17 -0500, Williams, Travis L, NPONS wrote:
> All,
> I'm not sure if I'm on the right track here.. I want to create a
> column that is automatically filled in with a unique number when a row is
> created.. I thought that creating a sequence would do this.. and then
> creating a column with a default of nextval('seqname') but it isn't doing
> anything.. any help is appreciated...
>

CREATE TEMP TABLE tempo (a text, id serial PRIMARY KEY);
INSERT INTO tempo VALUES ('foo');
INSERT INTO tempo VALUES ('bar');
SELECT * from tempo;

foo 1
bar 2

You can leave out the PRIMARY KEY, or insted use UNIQUE, or whatever ...

cu

--
Nabil Sayegh

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Giorgio A. 2001-06-07 21:49:55 Re: Create unique field..
Previous Message Williams, Travis L, NPONS 2001-06-07 19:58:17 Create unique field..