pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomasz Myrta <jasiek@klaster.net>
To: Arunachalam Jaisankar <arun_jaisankar@yahoo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to drop all the sequences
Date: Thu, 20 Feb 2003 21:39:32 +0100
Message-ID: <3E553D04.6070407@klaster.net> (raw)
References: <00fa01c2d8fe$c7918210$020000c0@singlarc01>

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




view thread (3+ messages)  latest in thread

Message-ID: <3E553D04.6070407@klaster.net>
Permalink:  ../3E553D04.6070407@klaster.net/
Also on:    postgresql.org/message-id/3E553D04.6070407@klaster.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jasiek@klaster.net, arun_jaisankar@yahoo.com
  Subject: Re: How to drop all the sequences
  In-Reply-To: <3E553D04.6070407@klaster.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox