Thread: How to drop all the sequences

How to drop all the sequences

From
"Arunachalam Jaisankar"
Date:
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
 

Re: How to drop all the sequences

From
Tomasz Myrta
Date:
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



Re: How to drop all the sequences

From
Oleg Samoylov
Date:
Arunachalam Jaisankar wrote:
> I found sequences are not getting dropped when tables are dropped. It is to=
> regards
> Jaisankar

In 7.3 sequence created automatically by serial field must be dropped 
with table.

-- 
Olleg Samoylov