Re: Create unique field..

Поиск
Список
Период
Сортировка
От Nabil Sayegh
Тема Re: Create unique field..
Дата
Msg-id 991944886.2619.0.camel@billy.labor.localnet
обсуждение исходный текст
Ответ на Create unique field..  ("Williams, Travis L, NPONS" <tlw@att.com>)
Список 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



В списке pgsql-novice по дате отправления:

Предыдущее
От: Ryan Ho
Дата:
Сообщение: Re: Multiple Columns Keys - Good or Bad idea?
Следующее
От: "Nabil Sayegh"
Дата:
Сообщение: Re: How do I start postmaster with -i for tcp-ip