note 89302 deleted from function.pg-meta-data by danbrown

From: Date: Mon, 02 Mar 2009 21:24:34 +0000
Subject: note 89302 deleted from function.pg-meta-data by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-151368@lists.php.net to get a copy of this message
Note Submitter: atzedus ---- Previous comment has a small bug, because it shows ALL table fields (i meen actual and DROPPED fields). You can get more usefull information with the following query: SELECT a.attname as name, FORMAT_TYPE(a.atttypid, null) as type, a.attlen as length, a.atthasdef as has_default, d.adsrc as default_value, a.attnotnull as is_notnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = 'TABLE_NAME'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum TABLE_NAME - may be simple name of table, or full table name with schema qualified, like "myschema"."table1". Without schema specified it will be searched thougth current "search_path" as usually.

« previous php.notes (#151368) next »