Обсуждение: how do I get the table name from a query?
When using the FE/BE, how do I retrieve the table name for a given column? Say I had the following SQL:
Select c.id, c.name, d.phone from Members c, Addresses d where c.id < 200
From the docs of the FE/BE, I would see that the fields are named id, name, phone but how do I find out the source tables that each field came from? I need to know this to discover nullability of fields, uniqueness, etc.
Thanks
Reggie
Reggie, At the moment, you can't, but please comment on my request for qualified column names. This is the same issue and there are many collateral issues which Tom has brought up. Dave On Mon, 2003-01-27 at 09:30, Reggie Burnett wrote: > When using the FE/BE, how do I retrieve the table name for a given > column? Say I had the following SQL: > > > > Select c.id, c.name, d.phone from Members c, Addresses d where c.id < > 200 > > > > From the docs of the FE/BE, I would see that the fields are named id, > name, phone but how do I find out the source tables that each field > came from? I need to know this to discover nullability of fields, > uniqueness, etc. > > > > Thanks > > Reggie -- Dave Cramer <dave@fastcrypt.com> Cramer Consulting
So unless I parse the SQL statement myself, I can't tell anything about the source table? To find out uniqueness, indexes, etc for fields in a source table, I need the table name and have to execute queries against pg_attribute and pg_indexes. But since the FE/BE doesn't return to me the source table name, I would have to parse this myself? Reggie > -----Original Message----- > From: pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers- > owner@postgresql.org] On Behalf Of Dave Cramer > Sent: Monday, January 27, 2003 8:42 AM > To: Reggie Burnett > Cc: 'Hackers' > Subject: Re: [HACKERS] how do I get the table name from a query? > > Reggie, > > At the moment, you can't, but please comment on my request for qualified > column names. This is the same issue and there are many collateral > issues which Tom has brought up. > > Dave > On Mon, 2003-01-27 at 09:30, Reggie Burnett wrote: > > When using the FE/BE, how do I retrieve the table name for a given > > column? Say I had the following SQL: > > > > > > > > Select c.id, c.name, d.phone from Members c, Addresses d where c.id < > > 200 > > > > > > > > From the docs of the FE/BE, I would see that the fields are named id, > > name, phone but how do I find out the source tables that each field > > came from? I need to know this to discover nullability of fields, > > uniqueness, etc. > > > > > > > > Thanks > > > > Reggie > -- > Dave Cramer <dave@fastcrypt.com> > Cramer Consulting > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org