From: Boulat Khakimov <boulat@inet-interactif.com>
To: pgsql-sql@postgresql.org
To: pgsql-general@postgresql.org
Subject: MySQLs Describe emulator!
Date: Mon, 05 Mar 2001 21:16:55 -0500
Message-ID: <3AA44897.121D60F0@inet-interactif.com> (raw)
Hi,
Here is a nifty query I came up with
that provides a detailed information on any row of any table.
Something that is build into mySQL (DESC tablename fieldname)
but not into PG.
SELECT a.attname AS Field,
c.typname as Type,
a.atttypmod-4 AS Size
FROM pg_attribute a,
pg_class b,
pg_type c
WHERE a.attrelid=b.oid
AND a.attname='[fieldname]'
AND b.relname='[tablename]'
AND c.OID=a.atttypid;
Output looks like this
funio=# SELECT a.attname AS Field, c.typname as Type,
funio-# a.atttypmod-4 AS Size
funio-# FROM pg_attribute a, pg_class b, pg_type c
funio-# WHERE a.attrelid=b.oid
funio-# AND a.attname='company'
funio-# AND b.relname='tbluser'
funio-# AND c.OID=a.atttypid;
field | type | size
---------+---------+------
company | varchar | 50
(1 row)
Pretty nifty huh? ;)
If I have time im gonna make a buildin function (DESC) out of it
--
Nothing Like the Sun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: boulat@inet-interactif.com, pgsql-general@postgresql.org
Subject: Re: MySQLs Describe emulator!
In-Reply-To: <3AA44897.121D60F0@inet-interactif.com>
References: <3AA44897.121D60F0@inet-interactif.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox