Re: [PERFORM] Auto generate number in Postgres-9.1.

Поиск
Список
Период
Сортировка
От Andreas Karlsson
Тема Re: [PERFORM] Auto generate number in Postgres-9.1.
Дата
Msg-id 84f4e415-02ef-b22b-8a3e-6d95b66b660b@proxel.se
обсуждение исходный текст
Ответ на Re: [PERFORM] Auto generate number in Postgres-9.1.  (Josh Berkus <josh@berkus.org>)
Список pgsql-performance
On 03/20/2017 02:43 PM, Josh Berkus wrote:
>> If I truncate the same table and then again insert rows should start
>> with 1 in “ID” column.
>
> That's not how it works, normally.  I'd suggest adding an ON TRUNCATE
> trigger to the table.

Actually that may not be necessary as long as you make sure to use the
RESTART IDENTITY option when running TRUNCATE. I would argue that is a
cleaner solution than using triggers, if you can get away with it.

https://www.postgresql.org/docs/9.6/static/sql-truncate.html

Andreas


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

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: [PERFORM] Auto generate number in Postgres-9.1.
Следующее
От: John Gorman
Дата:
Сообщение: Re: [PERFORM] Auto generate number in Postgres-9.1.