X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 1107A9FA293 for ; Tue, 9 May 2006 04:21:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 13833-07 for ; Tue, 9 May 2006 04:21:32 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web30409.mail.mud.yahoo.com (web30409.mail.mud.yahoo.com [68.142.200.112]) by postgresql.org (Postfix) with SMTP id BF5E19FA226 for ; Tue, 9 May 2006 04:21:32 -0300 (ADT) Received: (qmail 93531 invoked by uid 60001); 9 May 2006 07:21:29 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=4ifI3VvGHCvjfk97OiUxPuguOBICmOtlYym6AEGjouf16HDe38/AQMe6DoBVmao7YLWVy4DgCK2Hy1E0lSj0oy5NyTo+TbCXTJ7IsApD4WsgZ/NNRXFAtd1q2zK3QdU6S0yaxOwgqN57DJ0LHfOhwvqVtgk58sX+XogNL/Ub7e4= ; Message-ID: <20060509072129.93529.qmail@web30409.mail.mud.yahoo.com> Received: from [203.115.30.220] by web30409.mail.mud.yahoo.com via HTTP; Tue, 09 May 2006 00:21:29 PDT Date: Tue, 9 May 2006 00:21:29 -0700 (PDT) From: Thusitha Kodikara Subject: Re: FW: reset all sequences To: ptufenkji@usj.edu.lb, pgsql-admin@postgresql.org In-Reply-To: <200605090642.k496gTV8021264@Citrus.usj.edu.lb> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1547343378-1147159289=:90840" Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/78 X-Sequence-Number: 21610 --0-1547343378-1147159289=:90840 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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 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 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 --0-1547343378-1147159289=:90840 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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:
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

--0-1547343378-1147159289=:90840--