Re: List table with same column name

From: Peter Childs <blue(dot)dragon(at)blueyonder(dot)co(dot)uk>
To: achill(at)matrix(dot)gatewaynet(dot)com
Cc: Peter Childs <blue(dot)dragon(at)blueyonder(dot)co(dot)uk>, Abdul Wahab Dahalan <wahab(at)mimos(dot)my>, pgsql-sql(at)postgresql(dot)org
Subject: Re: List table with same column name
Date: 2003-10-23 09:09:42
Message-ID: Pine.LNX.4.58.0310231008050.13897@bluedragon.homelinux.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 23 Oct 2003 achill(at)matrix(dot)gatewaynet(dot)com wrote:

> On Thu, 23 Oct 2003, Peter Childs wrote:
>
> >
> >
> > On Thu, 23 Oct 2003 achill(at)matrix(dot)gatewaynet(dot)com wrote:
> >
> > > On Thu, 23 Oct 2003, Abdul Wahab Dahalan wrote:
> > >
> > > > Hi!
> > > > How do I list all the tables in the database which has a same column name?.
> > >
> > > SELECT t1.relname,a1.attname,t2.relname from pg_class t1,pg_attribute
> > > a1,pg_class t2,pg_attribute a2 where a1.attrelid=t1.oid and t1.relkind='r'
> > > and a1.attnum>0 and a2.attrelid=t2.oid and t2.relkind='r' and a2.attnum>0
> > > and t1.relname<t2.relname and a1.attname = a2.attname;
> >
> > That will not work.
> >
> > SELECT t1.relname,a1.attname,t2.relname from pg_class t1,pg_attribute
> > a1,pg_class t2,pg_attribute a2 where a1.attrelid=t1.oid and
> > t1.relkind='r'and a1.attnum>0 and a2.attrelid=t2.oid and t2.relkind='r'
> > and a2.attnum>0 and t1.relname<t2.relname and a1.attname = a2.attname and
> > a1.attisdropped=false and a2.attisdropped=false and t1.relname !=
> > t2.relname;
> >
> > Why?
> >
> > Well two bugs.
> > 1> Dropped Columns needed for 7.3.
> > 2> Do you really need to know that column a in table 1 also appears in
> > table 1?
>
> Have you ever thought that x<y implies x!=y ?

Yes but when I tested it due to pure intrest to told me that
column a in table 1 also appeared in table 1. Most strange.

Peter Childs

>
> >
> > Peter Childs
> >
> > >
> > > >
> > > > Thanks
> > > >
> > > >
> > > > ---------------------------(end of broadcast)---------------------------
> > > > TIP 4: Don't 'kill -9' the postmaster
> > > >
> > >
> > > --
> > > -Achilleus
> > >
> > >
> > > ---------------------------(end of broadcast)---------------------------
> > > TIP 5: Have you checked our extensive FAQ?
> > >
> > > http://www.postgresql.org/docs/faqs/FAQ.html
> > >
> >
>
> --
> -Achilleus
>
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Senthil Kumar S 2003-10-23 09:19:56 Error message during compressed backup
Previous Message achill 2003-10-23 09:08:47 Re: List table with same column name