Postgres and Ruby

Try this SQL, it might work. It resets the sequence number in a
table. Can be obviously modified to work on any table with a regular
unique non-null incrementing primary-key 'id'

SELECT setval('players_id_seq', (SELECT MAX(id) FROM players)+1);

Strictly speaking, you not need the "+1", as nextval() will increment it. The "+1" will actually create a hole in the sequence - which of course may or may not be if importance to your application.
    
16 nov 2007 kl. 15.55 skrev fredistic: