3

I have a database for which the comments on objects (PSQL command COMMENT) are just pollution for us: they are obsolete and in a language that no one reads in our organisation. Hence, I'd like to delete all these comments at once. There are hundreds of them and I don't want to write hundreds of command lines "COMMENT ON xxx IS NULL".

Anybody knows how to do this ?

2

Erwin Brandstetter gave a very good answer on how to do this on this question Removing COMMENT ON from all objects in PostgreSQL on Stack Overflow.

It basically consists of removing the comments directly from the system catalogues like so (disclaimer - the following code is copied directly from his answer):

DELETE FROM pg_description WHERE description = 'something special';

Or you could delete the comments based on any other criteria you may choose.

  • 1
    @Darth Kangooroo, in addition, you should also check out PhilHibbs answer in the same thread. He uses the information_schema to generate COMMENT statements. – Lennart Dec 21 '18 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.