Search Postgresql Archives

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]

 



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

-- 
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