Re: How to retrieve the comment for a constraint?
| От | Tom Lane |
|---|---|
| Тема | Re: How to retrieve the comment for a constraint? |
| Дата | |
| Msg-id | 26656.1111676724@sss.pgh.pa.us обсуждение |
| Ответ на | How to retrieve the comment for a constraint? (Wolfgang Drotschmann <drotschm@fgan.de>) |
| Список | pgsql-general |
Wolfgang Drotschmann <drotschm@fgan.de> writes:
> Now, imagine you know the name of a constraint or all of them for a given
> table, e.g. destilled via
> SELECT *
> FROM information_schema.table_constraints
> WHERE table_name = '<table_name>';
> How can I get the comment for each of these constraints?
Something like this...
regression=# alter table foo add constraint bar check(id > 0);
ALTER TABLE
regression=# comment on constraint bar on foo is 'check its positive';
COMMENT
regression=# select obj_description(oid, 'pg_constraint') from pg_constraint where conname = 'bar' and conrelid =
'foo'::regclass;
obj_description
--------------------
check its positive
(1 row)
You could join to pg_description explicitly instead of using
obj_description(), and/or join to pg_class instead of using regclass.
regards, tom lane
В списке pgsql-general по дате отправления: