Re: problem with serial
От | Chris Angelico |
---|---|
Тема | Re: problem with serial |
Дата | |
Msg-id | CAPTjJmp5AOuCEme4Tw-MPCX8Yx4zeUHr4SZsNGOtehLXGo2VaA@mail.gmail.com обсуждение исходный текст |
Ответ на | problem with serial (Yvon Thoraval <yvon.thoraval@gmail.com>) |
Ответы |
Re: problem with serial
|
Список | pgsql-general |
On Fri, Apr 20, 2012 at 12:19 AM, Yvon Thoraval <yvon.thoraval@gmail.com> wrote: > even if i rearrange de sequence by : > > "SELECT MAX(rowid) FROM items;"; > "SELECT last_value FROM items_rowid_seq;"; > then if last_value is lower than MAX(rowid) i set it to MAX(rowid) : > "SELECT setval('items_rowid_seq', max(rowid)) FROM items;"; As a side point, I would recommend against doing this. Once you've "used" a rowid, it's not worth reusing it. You'll save yourself some headaches down the track if you simply ignore those odd gaps (ditto the gaps that result from rolled-back transactions) and just DELETE the rows you're throwing out without bothering to setval the sequence back. ChrisA
В списке pgsql-general по дате отправления: