Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thomas Kellerer <spam_eater@xxxxxxx> writes:
> Belka Lambda wrote on 14.03.2010 01:24:
>> 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'

Relying on adsrc is a very bad idea.  I'd suggest
	pg_catalog.pg_get_expr(adbin, adrelid)
which is what pg_dump uses.

			regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux