Re: Resetting Serial Column Sequence Number

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: Resetting Serial Column Sequence Number
Дата
Msg-id 20061014063755.GA6530@KanotixBox
обсуждение исходный текст
Ответ на Resetting Serial Column Sequence Number  ("Adam" <adam@spatialsystems.org>)
Ответы Re: Resetting Serial Column Sequence Number  (Andreas Kretschmer <akretschmer@spamfence.net>)
Список pgsql-general
Adam <adam@spatialsystems.org> schrieb:

>
> I just emptied my table and I want all my new inserts to start with a
> 'location_id' of '1'. The table is named "locations" with a SERIAL column
> "location_id"
>
> I tried the below SQL to rest the sequence ID but it's not working.  What am I
> doing wrong?
>
> SELECT setval('locations_location_id_seq', (SELECT max(location_id) + 1 FROM
> locations));

The table locations are empty? Yeah, select max(location_id) from an
empty table is NULL, not 0. And NULL+1 -> NULL. You can't set a Sequence
to NULL, that makes no sense.


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."    (unknow)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

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

Предыдущее
От: "Adam"
Дата:
Сообщение: Resetting Serial Column Sequence Number
Следующее
От: Andreas Kretschmer
Дата:
Сообщение: Re: Resetting Serial Column Sequence Number