pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
resetting serials and sequences
2+ messages / 2 participants
[nested] [flat]

* resetting serials and sequences
@ 2001-01-01 15:48 Ferruccio Zamuner <nonsolosoft@diff.org>
  2001-01-01 22:01 ` Re: resetting serials and sequences Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Ferruccio Zamuner @ 2001-01-01 15:48 UTC (permalink / raw)
  To: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: resetting serials and sequences
  2001-01-01 15:48 resetting serials and sequences Ferruccio Zamuner <nonsolosoft@diff.org>
@ 2001-01-01 22:01 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2001-01-01 22:01 UTC (permalink / raw)
  To: Ferruccio Zamuner <nonsolosoft@diff.org>; +Cc: pgsql-sql

Ferruccio Zamuner <nonsolosoft@diff.org> writes:
> Is this a bug?         

No, but it is a missing feature: there's no way to reset a sequence's
is_called flag once it's been set.  This is fixed for 7.1: there's now
a three-parameter variant of setval() to let you do exactly that.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-01-01 22:01 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-01 15:48 resetting serials and sequences Ferruccio Zamuner <nonsolosoft@diff.org>
2001-01-01 22:01 ` Tom Lane <tgl@sss.pgh.pa.us>

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