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

From: Belka Lambda <lambda-belka(at)yandex(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: Is there any easy way to determine a default value specified for table column?
Date: 2010-03-14 00:24:11
Message-ID: 62171268526251@webmail102.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi everyone!

Is there a way to "nicely" determine a default value of a table column? A function, which could be used, like:
SELECT default_of('my_table.my_integer_column') :: integer;
?

I scanned pg_proc table:
===================================
postgres=# select proname from pg_proc where proname like '%dflt%' or proname like '%default%';
proname
------------------------
RI_FKey_setdefault_del
RI_FKey_setdefault_upd
(2 rows)
===================================
, so I guess there is no easy way to get a column default, is there?

I need it to imitate something like (notice COALESCE(...)):
INSERT INTO my_table (column1,column2,column3) VALUES (COALESCE($1, DEFAULT), 'column2_value', 'column3_value');

Regards,
Belka

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gordon Shannon 2010-03-14 05:35:20 Re: unexplained autovacuum to prevent wraparound
Previous Message fkater@googlemail.com 2010-03-13 20:33:01 libpq: compatibility with server versions