Re: STARTING SERIAL / BIGSERIAL FIELDS FROM 1.

Поиск
Список
Период
Сортировка
От Michael Wood
Тема Re: STARTING SERIAL / BIGSERIAL FIELDS FROM 1.
Дата
Msg-id 5a8aa6680907201258mc336287g708bd98793db73fe@mail.gmail.com
обсуждение исходный текст
Ответ на STARTING SERIAL / BIGSERIAL FIELDS FROM 1.  (JORGE MALDONADO <jorgemal1960@gmail.com>)
Список pgsql-novice
2009/7/20 JORGE MALDONADO <jorgemal1960@gmail.com>:
> How can a serial or bigserial field start from 1 again?
> I need to manually remove all the records from a table and I need these kind
> of fields to start from 1 once again.

If you use pg_dump on the database you should see something like this:

SELECT pg_catalog.setval('table_column_seq', 123456789, true);

That means that the last value will be set to 123456789 if you restore
using this dump.

You can do something like this, except that you can't set it to 0, so
you need to do this instead:

SELECT pg_catalog.setval('table_column_seq', 1, false);

Then the next value used would be 1.

--
Michael Wood <esiotrot@gmail.com>

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

Предыдущее
От: Jure Kobal
Дата:
Сообщение: Re: STARTING SERIAL / BIGSERIAL FIELDS FROM 1.
Следующее
От: Mike
Дата:
Сообщение: Re: How to insert data from a text file