Column names and datatypes

Started by Glenn Sullivanalmost 22 years ago4 messagesgeneral
Jump to latest
#1Glenn Sullivan
glenn.sullivan@varianinc.com

I need to acquire the list of all column names and datatypes
from a table through the JDBC interface using an sql command.
What I want is available in "psql" with the "\d tablename"
command, but I cannot figure out how to get these via an sql
command. Can anyone help?

Thanks,

Glenn

#2Carl E. McMillin
carlymac@earthlink.net
In reply to: Glenn Sullivan (#1)
Re: Column names and datatypes

Use getMetadata of Connection. According to jdocs, the DatabaseMetaData
object can probably give you what you are looking for.

Carl <|};-)>

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Glenn Sullivan
Sent: Friday, May 14, 2004 12:23 PM
To: pgsql-general
Subject: [GENERAL] Column names and datatypes

I need to acquire the list of all column names and datatypes from a table
through the JDBC interface using an sql command. What I want is available in
"psql" with the "\d tablename" command, but I cannot figure out how to get
these via an sql command. Can anyone help?

Thanks,

Glenn

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

#3Mike Mascari
mascarm@mascari.com
In reply to: Glenn Sullivan (#1)
Re: Column names and datatypes

Glenn Sullivan wrote:

I need to acquire the list of all column names and datatypes
from a table through the JDBC interface using an sql command.
What I want is available in "psql" with the "\d tablename"
command, but I cannot figure out how to get these via an sql
command. Can anyone help?

You can either query the information_schema's tables and views, or
you can start psql with the '-E' switch and view the queries its
sending and modify them to fit your requirements.

http://www.postgresql.org/docs/7.4/static/information-schema.html

HTH,

Mike Mascari

#4Glenn Sullivan
glenn.sullivan@varianinc.com
In reply to: Carl E. McMillin (#2)
Re: Column names and datatypes

Carl,

That is what I need. Thanks.

Glenn

Carl E. McMillin wrote:

Show quoted text

Use getMetadata of Connection. According to jdocs, the DatabaseMetaData
object can probably give you what you are looking for.

Carl <|};-)>

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Glenn Sullivan
Sent: Friday, May 14, 2004 12:23 PM
To: pgsql-general
Subject: [GENERAL] Column names and datatypes

I need to acquire the list of all column names and datatypes from a table
through the JDBC interface using an sql command. What I want is available in
"psql" with the "\d tablename" command, but I cannot figure out how to get
these via an sql command. Can anyone help?

Thanks,

Glenn

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend