Re: How to drop all the sequences

From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: Arunachalam Jaisankar <arun_jaisankar(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to drop all the sequences
Date: 2003-02-20 20:39:32
Message-ID: 3E553D04.6070407@klaster.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jeff Boes 2003-02-20 20:59:19 Re: EXCEPT Queries
Previous Message Josh Berkus 2003-02-20 19:20:44 Re: PL/PGSQL EDITOR