pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
SQL request to  retrieve the type of columns
3+ messages / 3 participants
[nested] [flat]

* SQL request to  retrieve the type of columns
@ 2002-02-12 15:45  Jean-Max Reymond <Jean-Max.Reymond@bull.net>
  0 siblings, 1 reply; 3+ messages in thread

From: Jean-Max Reymond @ 2002-02-12 15:45 UTC (permalink / raw)
  To: pgsql-sql

I am looking for a SQL request (must be executed in a ECPG program) to
retrieve the type of each column in a Postgres table.

For example,
\d wapi
                 Table "wapi"
 Attribute  |         Type          | Modifier 
------------+-----------------------+----------
 wapinom    | character(8)          | 
 wapicall   | character varying(12) | 
 wapitrans  | character varying(4)  | 
 wapistruct | character varying(50) | 

It will be great to have the same result with a "select request".
regards,


-- 
Jean-Max Reymond
  
============================================================================
 Email  : Jean-Max.Reymond@bull.net
 Address:  BULL SLDV (Saint Laurent du Var)
============================================================================





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

* Re: SQL request to  retrieve the type of columns
@ 2002-02-12 15:52  Vivek Khera <khera@kcilink.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Vivek Khera @ 2002-02-12 15:52 UTC (permalink / raw)
  To: jean-max.reymond@bull.net

>>>>> "jr" == jean-max reymond <jean-max.reymond@bull.net> writes:

jr> It will be great to have the same result with a select request.
jr> regards,

man psql

read..read..read...

       -E, --echo-hidden
              Echoes the actual queries generated by \d and other
              backslash commands.  You can use this if  you  wish
              to include similar functionality into your own pro-
              grams. This is equivalent to setting  the  variable
              ECHO_HIDDEN from within psql.


-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD       +1-240-453-8497
AIM: vivekkhera Y!: vivek_khera   http://www.khera.org/~vivek/



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

* Re: SQL request to  retrieve the type of columns
@ 2002-02-12 17:40  Andrew G. Hammond <drew@xyzzy.dhs.org>
  parent: Jean-Max Reymond <Jean-Max.Reymond@bull.net>
  0 siblings, 0 replies; 3+ messages in thread

From: Andrew G. Hammond @ 2002-02-12 17:40 UTC (permalink / raw)
  To: Jean-Max Reymond <Jean-Max.Reymond@bull.net>; +Cc: pgsql-sql

On Tue, Feb 12, 2002 at 04:45:55PM +0100, Jean-Max Reymond wrote:
> I am looking for a SQL request (must be executed in a ECPG program) to
> retrieve the type of each column in a Postgres table.
> 
> For example,
> \d wapi
>                 Table "wapi"
> Attribute  |         Type          | Modifier 
> ------------+-----------------------+----------
> wapinom    | character(8)          | 
> wapicall   | character varying(12) | 
> wapitrans  | character varying(4)  | 
> wapistruct | character varying(50) | 

From the psql man page section on variables:

ECHO_HIDDEN
When this variable is set and a  backslash  command
queries  the  database,  the  query is first shown.
This way you can study the Postgres  internals  and
provide similar functionality in your own programs.
If you set the variable to  the  value  ``noexec'',
the  queries  are  just  shown but are not actually
sent to the backend and executed.

\set ECHO_HIDDEN
CREATE TABLE foo (foo_id SERIAL PRIMARY KEY, name TEXT NOT NULL );
\d foo
                               Table "foo"
 Attribute |  Type   |                      Modifier
-----------+---------+----------------------------------------------------
 foo_id    | integer | not null default nextval('"foo_foo_id_seq"'::text)
 name      | text    | not null
Index: foo_pkey

-- 
Andrew G. Hammond     mailto:drew@xyzzy.dhs.org   http://xyzzy.dhs.org/~drew/
56 2A 54 EF 19 C0 3B 43 72 69 5B E3 69 5B A1 1F                  613-389-5481
5CD3 62B0 254B DEB1 86E0  8959 093E F70A B457 84B1
"To blow recursion you must first blow recur" -- me

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


end of thread, other threads:[~2002-02-12 17:40 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-02-12 15:45 SQL request to  retrieve the type of columns Jean-Max Reymond <Jean-Max.Reymond@bull.net>
2002-02-12 17:40 ` Andrew G. Hammond <drew@xyzzy.dhs.org>
2002-02-12 15:52 Re: SQL request to  retrieve the type of columns Vivek Khera <khera@kcilink.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