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 ?
-
You have not accepted an answer to any of your questions, yet. Please read meta.stackexchange.com/questions/5234/… and be more cooperative.Erwin Brandstetter– Erwin Brandstetter2019年01月25日 01:17:05 +00:00Commented Jan 25, 2019 at 1:17
1 Answer 1
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 - Slava Ukraini– Lennart - Slava Ukraini2018年12月21日 20:44:53 +00:00Commented Dec 21, 2018 at 20:44