how do I get the table name from a query?

Started by Reggie Burnettalmost 23 years ago3 messages
#1Reggie Burnett
rykr@bellsouth.net

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

#2Dave Cramer
dave@fastcrypt.com
In reply to: Reggie Burnett (#1)
Re: 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

#3Reggie Burnett
rykr@bellsouth.net
In reply to: Dave Cramer (#2)
Re: how do I get the table name from a query?

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)---------------------------

Show quoted text

TIP 6: Have you searched our list archives?

http://archives.postgresql.org