pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
MySQLs Describe emulator!
14+ messages / 10 participants
[nested] [flat]

* MySQLs Describe emulator!
@ 2001-03-06 02:16 Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 02:46 ` Re: MySQLs Describe emulator! Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-06 16:03 ` Re: [SQL] MySQLs Describe emulator! clayton cottingham <drfrog@smartt.com>
  0 siblings, 2 replies; 14+ messages in thread

From: Boulat Khakimov @ 2001-03-06 02:16 UTC (permalink / raw)
  To: pgsql-sql; pgsql-general@postgresql.org

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



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
@ 2001-03-06 02:46 ` Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-06 04:48   ` Re: MySQLs Describe emulator! Gregory Wood <gregw@com-stock.com>
  2001-03-06 14:14   ` Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  1 sibling, 2 replies; 14+ messages in thread

From: Tom Lane @ 2001-03-06 02:46 UTC (permalink / raw)
  To: Boulat Khakimov <boulat@inet-interactif.com>; +Cc: pgsql-sql; pgsql-general@postgresql.org

Boulat Khakimov <boulat@inet-interactif.com> writes:
> 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.

Er, what's wrong with psql's "\d table" ?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 02:46 ` Re: MySQLs Describe emulator! Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-03-06 04:48   ` Gregory Wood <gregw@com-stock.com>
  1 sibling, 0 replies; 14+ messages in thread

From: Gregory Wood @ 2001-03-06 04:48 UTC (permalink / raw)
  To: PostgreSQL-General <pgsql-general@postgresql.org>

> Boulat Khakimov <boulat@inet-interactif.com> writes:
> > 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.
>
> Er, what's wrong with psql's "\d table" ?

Those without shell access (or those of us who have access but use tools
other than psql) would like in on the fun too :)

Greg




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 02:46 ` Re: MySQLs Describe emulator! Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-03-06 14:14   ` Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 14:55     ` Re: MySQLs Describe emulator! Karel Zak <zakkr@zf.jcu.cz>
  2001-03-06 15:38     ` Re: [SQL] Re: MySQLs Describe emulator! Michael Fork <mfork@toledolink.com>
  1 sibling, 2 replies; 14+ messages in thread

From: Boulat Khakimov @ 2001-03-06 14:14 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-sql; pgsql-general@postgresql.org

Tom Lane wrote:
> 
> Boulat Khakimov <boulat@inet-interactif.com> writes:
> > 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.
> 
> Er, what's wrong with psql's "\d table" ?


Hi,

1) "\d table" can only be used in psql, you cant run a query like that
using libpq for example

2) as a programmer I need to be able to find out as much info as
possible about any given field
   which is what "describe" for in mySQL.

Regards,
Boulat Khakimov
      

-- 
Nothing Like the Sun



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 02:46 ` Re: MySQLs Describe emulator! Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-06 14:14   ` Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
@ 2001-03-06 14:55     ` Karel Zak <zakkr@zf.jcu.cz>
  2001-03-06 15:19       ` Re: Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  1 sibling, 1 reply; 14+ messages in thread

From: Karel Zak @ 2001-03-06 14:55 UTC (permalink / raw)
  To: Boulat Khakimov <boulat@inet-interactif.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-sql; pgsql-general@postgresql.org


On Tue, Mar 06, 2001 at 09:14:54AM -0500, Boulat Khakimov wrote:
> Tom Lane wrote:
> > 
> > Boulat Khakimov <boulat@inet-interactif.com> writes:
> > > 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.
> > 
> > Er, what's wrong with psql's "\d table" ?
> 
> 2) as a programmer I need to be able to find out as much info as
> possible about any given field
>    which is what "describe" for in mySQL.

 As a programmer you can see psql source and directly found how SQL
query execute this tool. The PostgreSQL needn't non-standard statements
like MySQL's SHOW, DESC -- the postgreSQL has system catalogs.

		Karel

-- 
 Karel Zak  <zakkr@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/
 
 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Re: MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 02:46 ` Re: MySQLs Describe emulator! Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-06 14:14   ` Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 14:55     ` Re: MySQLs Describe emulator! Karel Zak <zakkr@zf.jcu.cz>
@ 2001-03-06 15:19       ` Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 15:29         ` Re: Re: MySQLs Describe emulator! Michelle Murrain <mpm@norwottuck.com>
  2001-03-06 15:29         ` Re: Re: MySQLs Describe emulator! Alfred Perlstein <bright@wintelcom.net>
  2001-03-06 15:37         ` Re: Re: MySQLs Describe emulator! Karel Zak <zakkr@zf.jcu.cz>
  0 siblings, 3 replies; 14+ messages in thread

From: Boulat Khakimov @ 2001-03-06 15:19 UTC (permalink / raw)
  To: Karel Zak <zakkr@zf.jcu.cz>; pgsql-sql; pgsql-general@postgresql.org


Karel Zak wrote:
> > On Tue, Mar 06, 2001 at 09:14:54AM -0500, Boulat Khakimov wrote:
> > Tom Lane wrote:
> > >
> > > Boulat Khakimov <boulat@inet-interactif.com> writes:
> > > > 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.
> > >
> > > Er, what's wrong with psql's "\d table" ?
> >
> > 2) as a programmer I need to be able to find out as much info as
> > possible about any given field
> >    which is what "describe" for in mySQL.
> 
>  As a programmer you can see psql source and directly found how SQL
> query execute this tool. The PostgreSQL needn't non-standard statements
> like MySQL's SHOW, DESC -- the postgreSQL has system catalogs.
> 
>                 Karel

Agreed! Why make someones life easier?? 
Let's complicate things as much as possible that way it's more
fun,right? ;o)

Dont understand how this works?  No problem -- just read the source
code.
Dont understand how to get that to work? Not a problem -- read the
source code!

The only problem tho, the source codes tend to be thousands of lines
when it comes
to DBs and time is ... 

Regards,
Boulat Khakimov

-- 
Nothing Like the Sun



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Re: MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 02:46 ` Re: MySQLs Describe emulator! Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-06 14:14   ` Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 14:55     ` Re: MySQLs Describe emulator! Karel Zak <zakkr@zf.jcu.cz>
  2001-03-06 15:19       ` Re: Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
@ 2001-03-06 15:29         ` Michelle Murrain <mpm@norwottuck.com>
  2 siblings, 0 replies; 14+ messages in thread

From: Michelle Murrain @ 2001-03-06 15:29 UTC (permalink / raw)
  To: Boulat Khakimov <boulat@inet-interactif.com>; Karel Zak <zakkr@zf.jcu.cz>; pgsql-sql; pgsql-general@postgresql.org

On Tuesday 06 March 2001 10:19 am, Boulat Khakimov wrote:
> Karel Zak wrote:
> > > On Tue, Mar 06, 2001 at 09:14:54AM -0500, Boulat Khakimov wrote:
> > >
> > > Tom Lane wrote:
> > > > Boulat Khakimov <boulat@inet-interactif.com> writes:
> > > > > 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.
> > > >
> > > > Er, what's wrong with psql's "\d table" ?
> > >
> > > 2) as a programmer I need to be able to find out as much info as
> > > possible about any given field
> > >    which is what "describe" for in mySQL.
> >
> >  As a programmer you can see psql source and directly found how SQL
> > query execute this tool. The PostgreSQL needn't non-standard statements
> > like MySQL's SHOW, DESC -- the postgreSQL has system catalogs.
> >
> >                 Karel
>
> Agreed! Why make someones life easier??
> Let's complicate things as much as possible that way it's more
> fun,right? ;o)
>
> Dont understand how this works?  No problem -- just read the source
> code.
> Dont understand how to get that to work? Not a problem -- read the
> source code!
>
> The only problem tho, the source codes tend to be thousands of lines
> when it comes
> to DBs and time is ...

And, further, some of us are web programmers, and the source code doesn't 
help one whit in getting DATA that one needs to do stuff on the front end, 
like data entry validation.

Thanks much Boulat - you made the coding for my robust validator a lot easier 
to write and read... and it works well, too!

Michelle
------------
Michelle Murrain, Ph.D.
President
Norwottuck Technology Resources
mpm@norwottuck.com
http://www.norwottuck.com



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Re: MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 02:46 ` Re: MySQLs Describe emulator! Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-06 14:14   ` Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 14:55     ` Re: MySQLs Describe emulator! Karel Zak <zakkr@zf.jcu.cz>
  2001-03-06 15:19       ` Re: Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
@ 2001-03-06 15:29         ` Alfred Perlstein <bright@wintelcom.net>
  2 siblings, 0 replies; 14+ messages in thread

From: Alfred Perlstein @ 2001-03-06 15:29 UTC (permalink / raw)
  To: Boulat Khakimov <boulat@inet-interactif.com>; +Cc: Karel Zak <zakkr@zf.jcu.cz>; pgsql-sql; pgsql-general@postgresql.org

* Boulat Khakimov <boulat@inet-interactif.com> [010306 07:24] wrote:
> 
> Karel Zak wrote:
> > > On Tue, Mar 06, 2001 at 09:14:54AM -0500, Boulat Khakimov wrote:
> > > Tom Lane wrote:
> > > >
> > > > Boulat Khakimov <boulat@inet-interactif.com> writes:
> > > > > 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.
> > > >
> > > > Er, what's wrong with psql's "\d table" ?
> > >
> > > 2) as a programmer I need to be able to find out as much info as
> > > possible about any given field
> > >    which is what "describe" for in mySQL.
> > 
> >  As a programmer you can see psql source and directly found how SQL
> > query execute this tool. The PostgreSQL needn't non-standard statements
> > like MySQL's SHOW, DESC -- the postgreSQL has system catalogs.

FreeBSD has had some great successes because we're able to emulate
Linux, perhaps something in contrib or even the base system could
offer a MySQL compatibility module to help people ease into Postgresql
from Mysql?


-- 
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: Re: MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 02:46 ` Re: MySQLs Describe emulator! Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-06 14:14   ` Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 14:55     ` Re: MySQLs Describe emulator! Karel Zak <zakkr@zf.jcu.cz>
  2001-03-06 15:19       ` Re: Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
@ 2001-03-06 15:37         ` Karel Zak <zakkr@zf.jcu.cz>
  2001-03-07 00:09           ` Re: [SQL] Re: Re: MySQLs Describe emulator! Mathijs Brands <mathijs@ilse.nl>
  2 siblings, 1 reply; 14+ messages in thread

From: Karel Zak @ 2001-03-06 15:37 UTC (permalink / raw)
  To: Boulat Khakimov <boulat@inet-interactif.com>; +Cc: Karel Zak <zakkr@zf.jcu.cz>; pgsql-sql; pgsql-general@postgresql.org

On Tue, Mar 06, 2001 at 10:19:13AM -0500, Boulat Khakimov wrote:
> 
> Karel Zak wrote:
> > > On Tue, Mar 06, 2001 at 09:14:54AM -0500, Boulat Khakimov wrote:
> > > Tom Lane wrote:
> > > >
> > > > Boulat Khakimov <boulat@inet-interactif.com> writes:
> > > > > 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.
> > > >
> > > > Er, what's wrong with psql's "\d table" ?
> > >
> > > 2) as a programmer I need to be able to find out as much info as
> > > possible about any given field
> > >    which is what "describe" for in mySQL.
> > 
> >  As a programmer you can see psql source and directly found how SQL
> > query execute this tool. The PostgreSQL needn't non-standard statements
> > like MySQL's SHOW, DESC -- the postgreSQL has system catalogs.
> > 
> >                 Karel
> 
> Agreed! Why make someones life easier?? 
> Let's complicate things as much as possible that way it's more
> fun,right? ;o)
> 
> Dont understand how this works?  No problem -- just read the source
> code.
> Dont understand how to get that to work? Not a problem -- read the
> source code!
> 
> The only problem tho, the source codes tend to be thousands of lines
> when it comes
> to DBs and time is ... 

 Well man, I not write this code, but I need 1 minute for found it....

 see src/bin/psql/describe.c:

SELECT 	a.attname, format_type(a.atttypid, a.atttypmod), attnotnull,
	a.atthasdef, a.attnum, obj_description(a.oid) 
FROM 	pg_class c, pg_attribute a 
WHERE 	c.relname = 'YourTableName' AND 
		     ^^^^^^^^^^^^^
	a.attnum > 0 AND 
	a.attrelid = c.oid 
ORDER BY a.attnum;

 If I good remenber anywhere in PG's docs is catalog schema. It isn't
too much difficult write queries like above-mentioned, because catalog
attributes/tables names are intuitive. For start see pg_class and
pg_attribute.

		Karel

-- 
 Karel Zak  <zakkr@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/
 
 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [SQL] Re: Re: MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 02:46 ` Re: MySQLs Describe emulator! Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-06 14:14   ` Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 14:55     ` Re: MySQLs Describe emulator! Karel Zak <zakkr@zf.jcu.cz>
  2001-03-06 15:19       ` Re: Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 15:37         ` Re: Re: MySQLs Describe emulator! Karel Zak <zakkr@zf.jcu.cz>
@ 2001-03-07 00:09           ` Mathijs Brands <mathijs@ilse.nl>
  2001-03-07 08:48             ` Re: [SQL] Re: Re: MySQLs Describe emulator! Karel Zak <zakkr@zf.jcu.cz>
  0 siblings, 1 reply; 14+ messages in thread

From: Mathijs Brands @ 2001-03-07 00:09 UTC (permalink / raw)
  To: Karel Zak <zakkr@zf.jcu.cz>; +Cc: Boulat Khakimov <boulat@inet-interactif.com>; pgsql-sql; pgsql-general@postgresql.org

On Tue, Mar 06, 2001 at 04:37:32PM +0100, Karel Zak allegedly wrote:
> On Tue, Mar 06, 2001 at 10:19:13AM -0500, Boulat Khakimov wrote:
> > 
> > Karel Zak wrote:
> > > > On Tue, Mar 06, 2001 at 09:14:54AM -0500, Boulat Khakimov wrote:
> > > > Tom Lane wrote:
> > > > >
> > > > > Boulat Khakimov <boulat@inet-interactif.com> writes:
> > > > > > 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.
> > > > >
> > > > > Er, what's wrong with psql's "\d table" ?
> > > >
> > > > 2) as a programmer I need to be able to find out as much info as
> > > > possible about any given field
> > > >    which is what "describe" for in mySQL.
> > > 
> > >  As a programmer you can see psql source and directly found how SQL
> > > query execute this tool. The PostgreSQL needn't non-standard statements
> > > like MySQL's SHOW, DESC -- the postgreSQL has system catalogs.
> > > 
> > >                 Karel
> > 
> > Agreed! Why make someones life easier?? 
> > Let's complicate things as much as possible that way it's more
> > fun,right? ;o)
> > 
> > Dont understand how this works?  No problem -- just read the source
> > code.
> > Dont understand how to get that to work? Not a problem -- read the
> > source code!
> > 
> > The only problem tho, the source codes tend to be thousands of lines
> > when it comes
> > to DBs and time is ... 
> 
>  Well man, I not write this code, but I need 1 minute for found it....
> 
>  see src/bin/psql/describe.c:
> 
> SELECT 	a.attname, format_type(a.atttypid, a.atttypmod), attnotnull,
> 	a.atthasdef, a.attnum, obj_description(a.oid) 
> FROM 	pg_class c, pg_attribute a 
> WHERE 	c.relname = 'YourTableName' AND 
> 		     ^^^^^^^^^^^^^
> 	a.attnum > 0 AND 
> 	a.attrelid = c.oid 
> ORDER BY a.attnum;
> 
>  If I good remenber anywhere in PG's docs is catalog schema. It isn't
> too much difficult write queries like above-mentioned, because catalog
> attributes/tables names are intuitive. For start see pg_class and
> pg_attribute.

Karel, how about this one? It's even easier :) No need to spit through code
to find this...

serv0:/var/namedsrc$ psql -E -c '\d nodes' iig
********* QUERY *********
SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules
FROM pg_class WHERE relname='nodes'
*************************

********* QUERY *********
SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = 'nodes'
  AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid
ORDER BY a.attnum
*************************

********* QUERY *********
SELECT c2.relname
FROM pg_class c, pg_class c2, pg_index i
WHERE c.relname = 'nodes' AND c.oid = i.indrelid AND i.indexrelid = c2.oid
ORDER BY c2.relname
*************************

          Table "nodes"
 Attribute |   Type   | Modifier 
-----------+----------+----------
 id        | integer  | 
 title     | text     | 
 ncount    | smallint | 
 ecount    | smallint | 
 ref       | integer  | 
 moddate   | integer  | 
 publish   | char(1)  | 
Indices: idx_nodes_id,
         idx_nodes_ref,
         idx_nodes_title

Mathijs
-- 
It's not that perl programmers are idiots, it's that the language
rewards idiotic behavior in a way that no other language or tool has
ever done.
                                                    Erik Naggum



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [SQL] Re: Re: MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 02:46 ` Re: MySQLs Describe emulator! Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-06 14:14   ` Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 14:55     ` Re: MySQLs Describe emulator! Karel Zak <zakkr@zf.jcu.cz>
  2001-03-06 15:19       ` Re: Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 15:37         ` Re: Re: MySQLs Describe emulator! Karel Zak <zakkr@zf.jcu.cz>
  2001-03-07 00:09           ` Re: [SQL] Re: Re: MySQLs Describe emulator! Mathijs Brands <mathijs@ilse.nl>
@ 2001-03-07 08:48             ` Karel Zak <zakkr@zf.jcu.cz>
  0 siblings, 0 replies; 14+ messages in thread

From: Karel Zak @ 2001-03-07 08:48 UTC (permalink / raw)
  To: Mathijs Brands <mathijs@ilse.nl>; +Cc: Boulat Khakimov <boulat@inet-interactif.com>; pgsql-sql; pgsql-general@postgresql.org


On Wed, 7 Mar 2001, Mathijs Brands wrote:

> >  If I good remenber anywhere in PG's docs is catalog schema. It isn't
> > too much difficult write queries like above-mentioned, because catalog
> > attributes/tables names are intuitive. For start see pg_class and
> > pg_attribute.
> 
> Karel, how about this one? It's even easier :) No need to spit through code
> to find this...
> 
> serv0:/var/namedsrc$ psql -E -c '\d nodes' iig

 Yes, "-E" is better solution and I didn't know it, next time will probably
better see docs and help (psql --hepl) before start discussion like this.

 Thanks
	Karel

PS. ...but nobody be taken ill with source code :-)




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [SQL] Re: MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 02:46 ` Re: MySQLs Describe emulator! Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-06 14:14   ` Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
@ 2001-03-06 15:38     ` Michael Fork <mfork@toledolink.com>
  2001-03-09 19:43       ` Re: [SQL] Re: MySQLs Describe emulator! Patrick Welche <prlw1@newn.cam.ac.uk>
  1 sibling, 1 reply; 14+ messages in thread

From: Michael Fork @ 2001-03-06 15:38 UTC (permalink / raw)
  To: Boulat Khakimov <boulat@inet-interactif.com>; +Cc: pgsql-sql; pgsql-general@postgresql.org

try starting psql with the -E option -- this displays all queries used
internally to the screen, i.e.:

bash-2.04$ psql -E
********* QUERY *********
SELECT usesuper FROM pg_user WHERE usename = 'mfork'
*************************

Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

mfork=# \d test
********* QUERY *********
SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules
FROM pg_class WHERE relname='test'
*************************

********* QUERY *********
SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull,
a.atthasdef, a.attnum
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = 'test'
  AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid
ORDER BY a.attnum
*************************

        Table "test"
 Attribute | Type | Modifier 
-----------+------+----------
 t         | text | 
 d         | date | 


So to get the info displayed with \d, execute the query:

SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull,
a.atthasdef, a.attnum
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = '<<TABLE NAME>>' 
  AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid
ORDER BY a.attnum


Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio

On Tue, 6 Mar 2001, Boulat Khakimov wrote:

> Hi,
> 
> 1) "\d table" can only be used in psql, you cant run a query like that
> using libpq for example
> 
> 2) as a programmer I need to be able to find out as much info as
> possible about any given field
>    which is what "describe" for in mySQL.
> 
> Regards,
> Boulat Khakimov
>       
> 
> -- 
> Nothing Like the Sun
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> 




^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [SQL] Re: MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 02:46 ` Re: MySQLs Describe emulator! Tom Lane <tgl@sss.pgh.pa.us>
  2001-03-06 14:14   ` Re: MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
  2001-03-06 15:38     ` Re: [SQL] Re: MySQLs Describe emulator! Michael Fork <mfork@toledolink.com>
@ 2001-03-09 19:43       ` Patrick Welche <prlw1@newn.cam.ac.uk>
  0 siblings, 0 replies; 14+ messages in thread

From: Patrick Welche @ 2001-03-09 19:43 UTC (permalink / raw)
  To: Michael Fork <mfork@toledolink.com>; +Cc: Boulat Khakimov <boulat@inet-interactif.com>; pgsql-sql; pgsql-general@postgresql.org

On Tue, Mar 06, 2001 at 10:38:43AM -0500, Michael Fork wrote:
> try starting psql with the -E option -- this displays all queries used
> internally to the screen, i.e.:

Sorry, hadn't read this one before posting... Thanks to the "moderating" it'll
all be out of synch anyway but..

Patrick



^ permalink  raw  reply  [nested|flat] 14+ messages in thread

* Re: [SQL] MySQLs Describe emulator!
  2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
@ 2001-03-06 16:03 ` clayton cottingham <drfrog@smartt.com>
  1 sibling, 0 replies; 14+ messages in thread

From: clayton cottingham @ 2001-03-06 16:03 UTC (permalink / raw)
  To: Boulat Khakimov <boulat@inet-interactif.com>; psql-sql@postgresql.org; pgsql-general@postgresql.org

heya:



why not try:


drfrog=# \d messages
            Table "messages"
     Attribute     |  Type   | Modifier 
-------------------+---------+----------
 id                | integer | not null
 msgid             | text    | 
 boxid             | integer | 
 accountid         | integer | 
 date              | text    | 
 sentto            | text    | 
 sentfrom          | text    | 
 subject           | text    | 
 contenttype       | text    | 
 contentxferencode | text    | 
 mimeversion       | text    | 
 precedence        | text    | 
 approvedby        | text    | 
 inreplyto         | text    | 
 replyto           | text    | 
 listsub           | text    | 
 listunsub         | text    | 
 status            | text    | 
 xorigip           | text    | 
 cc                | text    | 
 bcc               | text    | 
 sender            | text    | 
 returnpath        | text    | 
 priority          | text    | 
 xmailer           | text    | 
 xuidl             | text    | 
 xsender           | text    | 
 localdate         | text    | 
 newmsg            | text    | 
 replyf            | integer | 
 friendly          | text    | 
 rreceiptto        | text    | 
 score             | integer | 
 ref               | text    | 
 serverstat        | integer | 
Index: messages_pkey



^ permalink  raw  reply  [nested|flat] 14+ messages in thread


end of thread, other threads:[~2001-03-09 19:43 UTC | newest]

Thread overview: 14+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-06 02:16 MySQLs Describe emulator! Boulat Khakimov <boulat@inet-interactif.com>
2001-03-06 02:46 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-03-06 04:48   ` Gregory Wood <gregw@com-stock.com>
2001-03-06 14:14   ` Boulat Khakimov <boulat@inet-interactif.com>
2001-03-06 14:55     ` Karel Zak <zakkr@zf.jcu.cz>
2001-03-06 15:19       ` Boulat Khakimov <boulat@inet-interactif.com>
2001-03-06 15:29         ` Michelle Murrain <mpm@norwottuck.com>
2001-03-06 15:29         ` Alfred Perlstein <bright@wintelcom.net>
2001-03-06 15:37         ` Karel Zak <zakkr@zf.jcu.cz>
2001-03-07 00:09           ` Mathijs Brands <mathijs@ilse.nl>
2001-03-07 08:48             ` Karel Zak <zakkr@zf.jcu.cz>
2001-03-06 15:38     ` Michael Fork <mfork@toledolink.com>
2001-03-09 19:43       ` Patrick Welche <prlw1@newn.cam.ac.uk>
2001-03-06 16:03 ` clayton cottingham <drfrog@smartt.com>

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