HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Postgresql: delete all comments from database

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqldeletealldatabasefromcomments

Problem

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 ?

Solution

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.

Code Snippets

DELETE FROM pg_description WHERE description = 'something special';

Context

StackExchange Database Administrators Q#225589, answer score: 2

Revisions (0)

No revisions yet.