pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedreset all sequences
7+ messages / 6 participants
[nested] [flat]
* reset all sequences
@ 2006-05-04 21:20 Sriram Dandapani <sdandapani@counterpane.com>
0 siblings, 1 reply; 7+ messages in thread
From: Sriram Dandapani @ 2006-05-04 21:20 UTC (permalink / raw)
To: pgsql-admin
Hi
I have a scenario where I need to reset all sequences(about 400). Is
there a system table that I can query to get a list of sequences
(Postgres 8.1.x)
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: reset all sequences
@ 2006-05-05 02:43 Bruno Wolff III <bruno@wolff.to>
parent: Sriram Dandapani <sdandapani@counterpane.com>
0 siblings, 0 replies; 7+ messages in thread
From: Bruno Wolff III @ 2006-05-05 02:43 UTC (permalink / raw)
To: Sriram Dandapani <sdandapani@counterpane.com>; +Cc: pgsql-admin
On Thu, May 04, 2006 at 14:20:39 -0700,
Sriram Dandapani <sdandapani@counterpane.com> wrote:
> Hi
>
>
>
> I have a scenario where I need to reset all sequences(about 400). Is
> there a system table that I can query to get a list of sequences
> (Postgres 8.1.x)
You can do something like:
select * from pg_class where relkind = 'S';
The relname column will give you the sequence name.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: reset all sequences
@ 2006-05-08 20:54 Sriram Dandapani <sdandapani@counterpane.com>
0 siblings, 0 replies; 7+ messages in thread
From: Sriram Dandapani @ 2006-05-08 20:54 UTC (permalink / raw)
To: Bruno Wolff III <bruno@wolff.to>; +Cc: pgsql-admin
Thanks..that really helped!!
-----Original Message-----
From: Bruno Wolff III [mailto:bruno@wolff.to]
Sent: Thursday, May 04, 2006 7:44 PM
To: Sriram Dandapani
Cc: pgsql-admin@postgresql.org
Subject: Re: reset all sequences
On Thu, May 04, 2006 at 14:20:39 -0700,
Sriram Dandapani <sdandapani@counterpane.com> wrote:
> Hi
>
>
>
> I have a scenario where I need to reset all sequences(about 400). Is
> there a system table that I can query to get a list of sequences
> (Postgres 8.1.x)
You can do something like:
select * from pg_class where relkind = 'S';
The relname column will give you the sequence name.
^ permalink raw reply [nested|flat] 7+ messages in thread
* FW: reset all sequences
@ 2006-05-09 06:38 Pascal Tufenkji <ptufenkji@usj.edu.lb>
0 siblings, 3 replies; 7+ messages in thread
From: Pascal Tufenkji @ 2006-05-09 06:38 UTC (permalink / raw)
To: pgsql-admin
Hi
How can I reset the sequence to "1"
If I use the following statement
Select setval('mytable_id_seq',1);
I put the last value as 1
So when I insert a new row the value will be "2" and not "1" as it should be
I cannot put Select setval('mytable_id_seq',0);
What should I do ??!!
Thx
Pascal
-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Sriram Dandapani
Sent: Monday, May 08, 2006 11:54 PM
To: Bruno Wolff III
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] reset all sequences
Thanks..that really helped!!
-----Original Message-----
From: Bruno Wolff III [mailto:bruno@wolff.to]
Sent: Thursday, May 04, 2006 7:44 PM
To: Sriram Dandapani
Cc: pgsql-admin@postgresql.org
Subject: Re: reset all sequences
On Thu, May 04, 2006 at 14:20:39 -0700,
Sriram Dandapani <sdandapani@counterpane.com> wrote:
> Hi
>
>
>
> I have a scenario where I need to reset all sequences(about 400). Is
> there a system table that I can query to get a list of sequences
> (Postgres 8.1.x)
You can do something like:
select * from pg_class where relkind = 'S';
The relname column will give you the sequence name.
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: FW: reset all sequences
@ 2006-05-09 06:42 Stephan Szabo <sszabo@megazone.bigpanda.com>
parent: Pascal Tufenkji <ptufenkji@usj.edu.lb>
2 siblings, 0 replies; 7+ messages in thread
From: Stephan Szabo @ 2006-05-09 06:42 UTC (permalink / raw)
To: Pascal Tufenkji <ptufenkji@usj.edu.lb>; +Cc: pgsql-admin
On Tue, 9 May 2006, Pascal Tufenkji wrote:
> How can I reset the sequence to "1"
>
> If I use the following statement
>
> Select setval('mytable_id_seq',1);
>
> I put the last value as 1
>
> So when I insert a new row the value will be "2" and not "1" as it should be
>
> I cannot put Select setval('mytable_id_seq',0);
>
> What should I do ??!!
You should be able to do this with the three argument form of setval as
setval('mytable_id_seq',1,false).
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: FW: reset all sequences
@ 2006-05-09 07:21 Thusitha Kodikara <kthusi@yahoo.com>
parent: Pascal Tufenkji <ptufenkji@usj.edu.lb>
2 siblings, 0 replies; 7+ messages in thread
From: Thusitha Kodikara @ 2006-05-09 07:21 UTC (permalink / raw)
To: ptufenkji@usj.edu.lb; pgsql-admin
Hi,
You could generate a common script to reset all the sequence using:
select 'alter sequence '||relname||' restart with 1 ;' from pg_class where relkind='S' ;
Then execute the output of that script to restart all the sequences from 1. Does that solve your problem?
Regards,
-Thusitha
Pascal Tufenkji <ptufenkji@usj.edu.lb> wrote: st1\:*{behavior:url(#default#ieooui) } Hi
How can I reset the sequence to “1”
If I use the following statement
Select setval('mytable_id_seq',1);
I put the last value as 1
So when I insert a new row the value will be “2” and not “1” as it should be
I cannot put Select setval('mytable_id_seq',0);
What should I do ??!!
Thx
Pascal
-----Original Message-----
From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Sriram Dandapani
Sent: Monday, May 08, 2006 11:54 PM
To: Bruno Wolff III
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] reset all sequences
Thanks..that really helped!!
-----Original Message-----
From: Bruno Wolff III [mailto:bruno@wolff.to]
Sent: Thursday, May 04, 2006 7:44 PM
To: Sriram Dandapani
Cc: pgsql-admin@postgresql.org
Subject: Re: reset all sequences
On Thu, May 04, 2006 at 14:20:39 -0700,
Sriram Dandapani <sdandapani@counterpane.com> wrote:
> Hi
>
>
>
> I have a scenario where I need to reset all sequences(about 400). Is
> there a system table that I can query to get a list of sequences
> (Postgres 8.1.x)
You can do something like:
select * from pg_class where relkind = 'S';
The relname column will give you the sequence name.
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: FW: reset all sequences
@ 2006-05-09 14:01 Ben K. <bkim@coe.tamu.edu>
parent: Pascal Tufenkji <ptufenkji@usj.edu.lb>
2 siblings, 0 replies; 7+ messages in thread
From: Ben K. @ 2006-05-09 14:01 UTC (permalink / raw)
To: Pascal Tufenkji <ptufenkji@usj.edu.lb>; +Cc: pgsql-admin
> Select setval('mytable_id_seq',1);
> So when I insert a new row the value will be "2" and not "1" as it should be
Select setval('mytable_id_seq',1,false);
http://www.postgresql.org/docs/8.1/interactive/functions-sequence.html
HTH.
Ben K.
Developer
http://benix.tamu.edu
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2006-05-09 14:01 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-05-04 21:20 reset all sequences Sriram Dandapani <sdandapani@counterpane.com>
2006-05-05 02:43 ` Bruno Wolff III <bruno@wolff.to>
2006-05-08 20:54 Re: reset all sequences Sriram Dandapani <sdandapani@counterpane.com>
2006-05-09 06:38 FW: reset all sequences Pascal Tufenkji <ptufenkji@usj.edu.lb>
2006-05-09 06:42 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
2006-05-09 07:21 ` Thusitha Kodikara <kthusi@yahoo.com>
2006-05-09 14:01 ` Ben K. <bkim@coe.tamu.edu>
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