Re: Make an id field max(id)+1 rather than SERIAL

Поиск
Список
Период
Сортировка
От Rory Campbell-Lange
Тема Re: Make an id field max(id)+1 rather than SERIAL
Дата
Msg-id 20020919170935.GA7462@campbell-lange.net
обсуждение исходный текст
Ответ на Re: Make an id field max(id)+1 rather than SERIAL  (Oliver Elphick <olly@lfix.co.uk>)
Список pgsql-novice
On 19/09/02, Oliver Elphick (olly@lfix.co.uk) wrote:
> On Thu, 2002-09-19 at 15:14, Rory Campbell-Lange wrote:
> > I have problems after exporting then importing data into newly created
> > databases that the sequence and the indexed serial fields get out of
> > alignment.
> >
> > I wonder if it isn't better to always simply insert ids using some sort
> > of function or other procedure to calculate on each insert a new unique
> > id number.
>
> After you import data, you must also reset the sequence:
>
>   SELECT setval('sequence_name',
>         (SELECT MAX(sequence_column) FROM table));

Excellent stuff. Thanks.
Rory
--
Rory Campbell-Lange
<rory@campbell-lange.net>
<www.campbell-lange.net>

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

Предыдущее
От: Oliver Elphick
Дата:
Сообщение: Re: Make an id field max(id)+1 rather than SERIAL
Следующее
От: "Thilo Hille"
Дата:
Сообщение: table corruption... :(