On Fri, Apr 20, 2012 at 12:19 AM, Yvon Thoraval <yvon.thoraval@xxxxxxxxx> 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 -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general