Resetting Serial Column Sequence Number

From: "Adam" <adam(at)spatialsystems(dot)org>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Resetting Serial Column Sequence Number
Date: 2006-10-14 04:25:20
Message-ID: 000b01c6ef48$c3029d10$0200a8c0@PANASONIULSWMR
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I just emptied my table and I want all my new inserts to start with a 'location_id' of '1'. The table is named "locations" with a SERIAL column "location_id"

I tried the below SQL to rest the sequence ID but it's not working. What am I doing wrong?

SELECT setval('locations_location_id_seq', (SELECT max(location_id) + 1 FROM locations));

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Kretschmer 2006-10-14 06:37:55 Re: Resetting Serial Column Sequence Number
Previous Message Jan Cruz 2006-10-14 04:12:25 Re: Versioning/updating schema