FW: reset all sequences

From: "Pascal Tufenkji" <ptufenkji(at)usj(dot)edu(dot)lb>
To: <pgsql-admin(at)postgresql(dot)org>
Subject: FW: reset all sequences
Date: 2006-05-09 06:38:24
Message-ID: 200605090642.k496gTV8021264@Citrus.usj.edu.lb
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)postgresql(dot)org
[mailto:pgsql-admin-owner(at)postgresql(dot)org] On Behalf Of Sriram Dandapani
Sent: Monday, May 08, 2006 11:54 PM
To: Bruno Wolff III
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: [ADMIN] reset all sequences

Thanks..that really helped!!

-----Original Message-----

From: Bruno Wolff III [mailto:bruno(at)wolff(dot)to]

Sent: Thursday, May 04, 2006 7:44 PM

To: Sriram Dandapani

Cc: pgsql-admin(at)postgresql(dot)org

Subject: Re: reset all sequences

On Thu, May 04, 2006 at 14:20:39 -0700,

Sriram Dandapani <sdandapani(at)counterpane(dot)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(at)postgresql(dot)org so that your

message can get through to the mailing list cleanly

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Stephan Szabo 2006-05-09 06:42:38 Re: FW: reset all sequences
Previous Message mindtree.chandana 2006-05-09 04:45:01 Query