Re: Is there any easy way to determine a default value specified for table column?

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Is there any easy way to determine a default value specified for table column?
Дата
Msg-id hnjb8s$obs$1@dough.gmane.org
обсуждение исходный текст
Ответ на Is there any easy way to determine a default value specified for table column?  (Belka Lambda <lambda-belka@yandex.ru>)
Ответы Re: Re: Is there any easy way to determine a default value specified for table column?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Belka Lambda wrote on 14.03.2010 01:24:
> Hi everyone!
>
> Is there a way to "nicely" determine a default value of a table column? A function, which could be used, like:

The defaults are store in pg_attrdef, the corresponding column definitions in pg_attribute.

So you would need to do a join between the two tables, something like:

select c.relname, a.attname, def.adsrc
from pg_attrdef def
   join pg_class c on def.adrelid = c.oid
   join pg_attribute a on a.attrelid = c.oid and a.attnum = def.adnum
where c.relname = 'the_table_name'

Thomas



В списке pgsql-general по дате отправления:

Предыдущее
От: Belka Lambda
Дата:
Сообщение: Is there any easy way to determine a default value specified for table column?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Re: Is there any easy way to determine a default value specified for table column?