Can you retrieve column Default value in Pgsql?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
myleow
Forum Contributor
Posts: 194
Joined: Mon Jun 21, 2004 7:05 pm
Location: California

Can you retrieve column Default value in Pgsql?

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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;
Post Reply