From: | "Carl E(dot) McMillin" <carlymac(at)earthlink(dot)net> |
---|---|
To: | "'Scot L(dot) Harris'" <webid(at)cfl(dot)rr(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: table column information |
Date: | 2004-05-16 20:58:12 |
Message-ID: | 000801c43b88$83268fb0$6600a8c0@DEVSONY |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
> Use getMetadata of java.sql.Connection. According to jdocs, the
> DatabaseMetaData object can probably give you what you are looking for.
Carl <|};-)>
-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Scot L. Harris
Sent: Sunday, May 16, 2004 1:22 PM
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] table column information
Currently using Postgresql 7.2.4-5.80 with php 4.2.2.-8.0.8 on a redhat 8.0
system.
I am writing some php scripts where I want to generate a list of the column
names in a particular table that the user selects. I could take the brute
force method and hard code the column names but then every time I add a new
table or modify an existing one I would have to modify the code. What I
want is to have a generic function that given the table name it will pull
the column names for my use.
I need to get the table column names for several tables I have setup. I
know if I do a select * from tablename I can then use the pg_fieldname
function to pull the column names for all columns.
But I don't think I want to select the entire contents of the table every
time I want to get the names of the columns. I know this will work but I
think performance will be very poor.
Trying to find something the equivalent of doing a \d tablename in psql.
I did see a function to pull meta data but that is in a 4.3 version of php.
I have also been trying to track down some information on the pga_layout
table. This appears to be a system table that might contain the information
I want but it does not list every table I have created. Not sure what that
is.
The books I have do not say much if anything about such system tables.
Any help or pointers would be appreciated.
--
Scot L. Harris <webid(at)cfl(dot)rr(dot)com>
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly
From | Date | Subject | |
---|---|---|---|
Next Message | Scot L. Harris | 2004-05-16 21:27:23 | Re: table column information |
Previous Message | Stephan Szabo | 2004-05-16 20:55:30 | Re: one to many |