note 89302 added to function.pg-meta-data
| From: | atzedus at osu1 dot php dot net | Date: | Mon, 02 Mar 2009 21:21:44 +0000 |
| Subject: | note 89302 added to function.pg-meta-data | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-151367@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 78.41.104.32
Probable Submitter: 80.90.119.73
----
Manual Page -- http://www.php.net/manual/en/function.pg-meta-data.php
Edit -- https://master.php.net/note/edit/89302
Del: integrated -- https://master.php.net/note/delete/89302/integrated
Del: useless -- https://master.php.net/note/delete/89302/useless
Del: bad code -- https://master.php.net/note/delete/89302/bad+code
Del: spam -- https://master.php.net/note/delete/89302/spam
Del: non-english -- https://master.php.net/note/delete/89302/non-english
Del: in docs -- https://master.php.net/note/delete/89302/in+docs
Del: other reasons-- https://master.php.net/note/delete/89302
Reject -- https://master.php.net/note/reject/89302
Search -- https://master.php.net/manage/user-notes.php