From: Ferruccio Zamuner <nonsolosoft@diff.org>
To: pgsql-sql@postgresql.org
Subject: resetting serials and sequences
Date: Mon, 1 Jan 2001 16:48:35 +0100 (CET)
Message-ID: <200101011548.f01FmZm13200@tnt.diff.org> (raw)
Hi,
#create temp table a (
id serial primary key,
name text not null);
#insert into a (name) values ('Tom');
#insert into a (name) values ('Fer');
#insert into a (name) values ('Mario');
#select * from a;
id | name
----+-------
1 | Tom
2 | Fer
3 | Mario
(3 rows)
OK. Now for some reason I need to reset everything without drop tables:
#delete from a;
#select setval ('a_id_seq', 1);
vacuum;
And now reinsert items:
#insert into a (name) values ('Tom');
#insert into a (name) values ('Fer');
#insert into a (name) values ('Mario');
#select * from a;
id | name
----+-------
2 | Tom
3 | Fer
4 | Mario
(3 rows)
We have missed the id "1"!!!
Otherway:
#select setval('a_id_seq', 0);
ERROR: a_id_seq.setval: value 0 is of of bounds (1,2147483647)
Is this a bug?
Best wishes for the brand new year \fer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: nonsolosoft@diff.org
Subject: Re: resetting serials and sequences
In-Reply-To: <200101011548.f01FmZm13200@tnt.diff.org>
References: <200101011548.f01FmZm13200@tnt.diff.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox