Обсуждение: DELETE FROM pg_description WHERE ...
Hi! It is generally not advisable to write to system catalogs directly ... However, I have a database with dozens of schemas and hundreds of tables. There is a bunch of useless comments on columns I want to get rid of, scattered all across the db. The fastest & easiest way would be: DELETE FROM pg_description WHERE description = 'My very special totally useless comment.'; AFAICS, there are no side-effects. Are there any? TIA! Erwin Brandstetter
Erwin Brandstetter <brsaweda@gmail.com> writes: > However, I have a database with dozens of schemas and hundreds of > tables. There is a bunch of useless comments on columns I want to get > rid of, scattered all across the db. The fastest & easiest way would > be: > DELETE FROM pg_description WHERE description = 'My very special > totally useless comment.'; > AFAICS, there are no side-effects. Are there any? It's safe enough, as long as you don't delete the wrong comments. There's no hidden infrastructure for a comment. regards, tom lane
On 23.04.2011 05:21, Tom Lane wrote: > Erwin Brandstetter<brsaweda@gmail.com> writes: >> However, I have a database with dozens of schemas and hundreds of >> tables. There is a bunch of useless comments on columns I want to get >> rid of, scattered all across the db. The fastest& easiest way would >> be: >> DELETE FROM pg_description WHERE description = 'My very special >> totally useless comment.'; >> AFAICS, there are no side-effects. Are there any? > It's safe enough, as long as you don't delete the wrong comments. > There's no hidden infrastructure for a comment. > > regards, tom lane > Thank you for your answers! Regards Erwin
On Fri, Apr 22, 2011 at 5:26 PM, Erwin Brandstetter <brsaweda@gmail.com> wrote: > Hi! > > It is generally not advisable to write to system catalogs directly ... > > However, I have a database with dozens of schemas and hundreds of > tables. There is a bunch of useless comments on columns I want to get > rid of, scattered all across the db. The fastest & easiest way would > be: > > DELETE FROM pg_description WHERE description = 'My very special > totally useless comment.'; Why would you *not* use the COMMENT command for that? What is slower or harder about using it? -- Simon Riggs http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
Simon Riggs <simon@2ndQuadrant.com> writes: > On Fri, Apr 22, 2011 at 5:26 PM, Erwin Brandstetter <brsaweda@gmail.com> wrote: >> DELETE FROM pg_description WHERE description = 'My very special >> totally useless comment.'; > Why would you *not* use the COMMENT command for that? If what he wants is to drop comments containing a particular string, COMMENT isn't an especially easy way to do it. regards, tom lane