-E parameter ?
from man psql:
...
PSQL(UNIX)
PostgreSQL
PSQL(UNIX)
-E Echo
the actual query generated by \d and other
backslash commands
-f filename
Use the file filename as the source of queries
instead of reading queries interactively.
...
anyway try this one: (replace MY_TABLE with your table name):
SELECT a.attnum, a.attname,
t.typname, a.attlen,
a.atttypmod, a.attnotnull,
a.atthasdef
FROM pg_class c, pg_attribute
a, pg_type t
WHERE c.relname = 'MY_TABLE'
and a.attnum > 0
and a.attrelid = c.oid
and a.atttypid = t.oid
ORDER BY
attnum ;
attnum|attname |typname|attlen|atttypmod|attnotnull|atthasdef
------+--------------+-------+------+---------+----------+---------
1|istat
|bpchar | -1| 10|t
|f
2|nome
|bpchar | -1| 54|t
|f
3|provincia |bpchar
| -1| 6|f
|f
4|codice_fiscale|bpchar |
-1| 8|f
|f
5|cap
|bpchar | -1|
9|f |f
6|regione
|bpchar | -1|
7|f |f
7|distretto |bpchar
| -1| 8|f
|f
(7 rows)
Jeff wrote:
That doesn't seem to work for me the -E switch doesn't exist, but the -e
(echo) does, which I assume you are referring to. The problem is that
postgress doesn't echo anything for \commands only real SQL commands.If it works on yours could you copy the echoed query and forward it to me.
Jeff Seese
> From: Jose Soares <[EMAIL PROTECTED]>
> Organization: Sfera Carta
> Newsgroups: muc.lists.postgres.questions
> Date: 20 Mar 2000 17:04:13 +0100
> Subject: Re: [GENERAL] How to retrieve table definition in SQL
>
> If you start pgsql with -E parameter
> when you type \d <tablename> pgsql shows you the query it executes to display
> the table definition.
>
>
> Stan Jacobs wrote:
>
>> Hi everyone,
>>
>> This probably isn't a Postgres-specific question, but I'm hoping that
>> someone knows the answer to this off the top of their heads... :-)
>>
>> I'd like to retrieve the table definition via SQL. I'm using ColdFusion
>> to access a PostgreSQL 6.5.3 database, and I'd like to retrieve the table
>> info, field names/types/sizes, so that my Coldfusion page/script can
>> dynamically build the html forms to edit the tables.
>>
>> Any ideas how to get to this in SQL? I have another C++ class which
>> builds nice table headers with this info, but ColdFusion doesn't seem to
>> do that with the returned data.
>>
>> Thanks!
>>
>> - Stan -
>
> --
> Jose' Soares
> Bologna, Italy [EMAIL PROTECTED]
>
>
>
--
Jose' Soares
Bologna, Italy
[EMAIL PROTECTED]