Steve Thames wrote:

>    SELECT a.attnum, n.nspname, c.relname, d.adsrc AS default_value 
>      FROM pg_attribute AS a 
>      JOIN pg_class     AS c ON a.attrelid     = c.oid 
>      JOIN pg_namespace AS n ON c.relnamespace = n.oid 
> LEFT JOIN pg_attrdef   AS d ON d.adrelid      = c.oid AND d.adnum = a.attnum
>     WHERE a.attnum > 0   
>       AND n.nspname = 'testschema'  
>       AND c.relname = 'testtable';

Don't ever rely on adsrc.  It's useless.  Use pg_get_expr(adbin)
instead.  That's safe, for instance, if the sequence gets renamed.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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

Reply via email to