How to delete unused sequences?

Posted by user1023877 on Stack Overflow See other posts from Stack Overflow or by user1023877
Published on 2011-11-25T06:36:45Z Indexed on 2011/11/26 9:53 UTC
Read the original article Hit count: 166

Filed under:
|
|

We are using PostgreSQL. My requirement is to delete unused sequences from my database. For example, if I create any table through my application, one sequence will be created, but for deleting the table we are not deleting the sequence, too. If want to create the same table another sequence is being created.

Example: table: file; automatically created sequence for id coumn: file_id_seq

When I delete the table file and create it with same name again, a new sequence is being created (i.e. file_id_seq1). I have accumulated a huge number of unused sequences in my application database this way.

How to delete these unused sequences?

© Stack Overflow or respective owner

Related posts about postgresql

Related posts about ddl