Re: Mass Import/Generate PKs

Поиск
Список
Период
Сортировка
От Ed L.
Тема Re: Mass Import/Generate PKs
Дата
Msg-id 200411061456.03458.pgsql@bluepolka.net
обсуждение исходный текст
Ответ на Re: Mass Import/Generate PKs  (Franco Bruno Borghesi <franco@akyasociados.com.ar>)
Ответы Re: Mass Import/Generate PKs
Список pgsql-general
On Saturday November 6 2004 2:13, Franco Bruno Borghesi wrote:
> the simplest way to do it seems to be adding a SERIAL column to your
> table, and then adding a primary key constraint:
>
> 1)insert data into table
> 2)ALTER TABLE <table> ADD id SERIAL;
> 3)ALTER TABLE <table> ADD CONSTRAINT <table>_pk PRIMARY KEY (id);

You may also need to populate the id column with unique values in between
these two steps with something like "

    update table set id = nextval('table_id_seq'::text) where id isnull"

I don't think SERIAL does that for you.

Ed


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

Предыдущее
От: Franco Bruno Borghesi
Дата:
Сообщение: Re: Mass Import/Generate PKs
Следующее
От: Franco Bruno Borghesi
Дата:
Сообщение: Re: Mass Import/Generate PKs