Re: FW: reset all sequences
От | Thusitha Kodikara |
---|---|
Тема | Re: FW: reset all sequences |
Дата | |
Msg-id | 20060509072129.93529.qmail@web30409.mail.mud.yahoo.com обсуждение исходный текст |
Ответ на | FW: reset all sequences ("Pascal Tufenkji" <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:
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:
HiHow can I reset the sequence to 1If I use the following statementSelect setval('mytable_id_seq',1);I put the last value as 1So when I insert a new row the value will be 2 and not 1 as it should beI cannot put Select setval('mytable_id_seq',0);What should I do ??!!ThxPascal-----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 sequencesThanks..that really helped!!-----Original Message-----From: Bruno Wolff III [mailto:bruno@wolff.to]Sent: Thursday, May 04, 2006 7:44 PMTo: Sriram DandapaniCc: pgsql-admin@postgresql.orgSubject: Re: reset all sequencesOn 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 appropriatesubscribe-nomail command to majordomo@postgresql.org so that yourmessage can get through to the mailing list cleanly
В списке pgsql-admin по дате отправления: