Page 1 of 1

Can you retrieve column Default value in Pgsql?

Posted: Thu Jan 06, 2005 3:36 pm
by myleow
Is it possible to retrieve the Default Value in Pgsql? I know you can use pg_meta_data to check if there exists Default but i can't find the PHP command to retrieve the value.

Regards
Mian

Posted: Thu Jan 06, 2005 4:15 pm
by feyd
a few searches turned up this:

Code: Select all

SELECT a.attname
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = 'tablename'
AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid
ORDER BY a.attnum;