Обсуждение: how do I get the table name from a query?

Поиск
Список
Период
Сортировка

how do I get the table name from a query?

От
"Reggie Burnett"
Дата:
<div class="Section1"><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">When using the FE/BE, how do I retrieve the table name for a given column?<span
style="mso-spacerun:yes"> </span>Say I had the following SQL:</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Select <span class="SpellE">c.id</span>, <span class="SpellE">c.name</span>, <span
class="SpellE">d.phone</span>from Members c, Addresses d where <span class="SpellE">c.id</span> <
200</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">From the docs of the FE/BE, I would see that the fields are named id, name, phone but how do I find
outthe source tables that each field came from?<span style="mso-spacerun:yes">  </span>I need to know this to discover
<spanclass="SpellE">nullability</span> of fields, uniqueness, etc.</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Thanks</span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Reggie</span></font></div>

Re: how do I get the table name from a query?

От
Dave Cramer
Дата:
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



Re: how do I get the table name from a query?

От
"Reggie Burnett"
Дата:
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