X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 44E6F475F22 for ; Thu, 20 Feb 2003 15:55:26 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 09906-07 for ; Thu, 20 Feb 2003 15:55:15 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id CF3BE475F53 for ; Thu, 20 Feb 2003 15:39:53 -0500 (EST) Received: from klaster.net (ph20.krakow.cvx.ppp.tpnet.pl [217.99.208.20]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 80FC32B88D; Thu, 20 Feb 2003 21:30:30 +0100 (CET) Message-ID: <3E553D04.6070407@klaster.net> Date: Thu, 20 Feb 2003 21:39:32 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; PL; rv:1.1) Gecko/20020826 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Arunachalam Jaisankar Cc: pgsql-sql@postgresql.org Subject: Re: How to drop all the sequences References: <00fa01c2d8fe$c7918210$020000c0@singlarc01> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/466 X-Sequence-Number: 11864 Arunachalam Jaisankar wrote: > I found sequences are not getting dropped when tables are dropped. It is > too difficult to drop all sequences one by one manually. Is there any > command to drop all sequences in a database? Looking for help. > > regards > Jaisankar Try this simple pl/pgsql function: create or replace function drop_all_sequences() returns integer as ' declare rec record; begin for rec in select relname as seqname from pg_class where relkind=''S'' loop execute ''drop sequence '' || rec.seqname; end loop; return 1; end; ' language 'plpgsql'; Regards, Tomasz Myrta