Обсуждение: DELETE FROM pg_description WHERE ...

Поиск
Список
Период
Сортировка

DELETE FROM pg_description WHERE ...

От
Erwin Brandstetter
Дата:
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

Re: DELETE FROM pg_description WHERE ...

От
Tom Lane
Дата:
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

Re: DELETE FROM pg_description WHERE ...

От
Erwin Brandstetter
Дата:
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


Re: DELETE FROM pg_description WHERE ...

От
Simon Riggs
Дата:
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

Re: DELETE FROM pg_description WHERE ...

От
Tom Lane
Дата:
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