From: | "Rodrigo Sakai" <rodrigo(dot)sakai(at)zanthus(dot)com(dot)br> |
---|---|
To: | "'Achilleus Mantzios'" <achill(at)matrix(dot)gatewaynet(dot)com> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | RES: Joins between int and int[] |
Date: | 2006-06-28 14:31:18 |
Message-ID: | 002501c69abf$84d524f0$4700a8c0@TREEZANTHUS |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Thanks Mantzios, your answer helped a lot! But I have a lot of multi column
foreign keys! Any other ideia??
Thanks in advance!
-----Mensagem original-----
De: Achilleus Mantzios [mailto:achill(at)matrix(dot)gatewaynet(dot)com]
Enviada em: quarta-feira, 28 de junho de 2006 04:01
Para: Rodrigo Sakai
Assunto: Re: [SQL] Joins between int and int[]
O Rodrigo Sakai Ýãñáøå óôéò Jun 27, 2006 :
> Hi,
>
>
>
> I want to use the system catalog tables/views to query some things, and
> one of the queries I have to do is joining pg_attribute and pg_constraint
to
> know what constraint belongs to which table.attribute. My question is how
> can I write the join clause between a int (pg_attribute.attnum) and int[ ]
> (pg_constraint.conkey).
Are you having tables with multi column foreign keys?
e.g. (a,b) REFERENCES partable(para,parb).
If not then join with pg_constraint.conkey[1],
if yes then the problem becomes a little less trivial.
>
>
>
>
>
> The query is:
>
>
>
> select relname, attname, attnotnull, atthasdef
>
> from pg_class as pc
>
> inner join pg_attribute as pa
>
> on pc.oid=pa.attrelid
>
> inner join pg_constraint pcons
>
> on pc.oid=pcons.conrelid
>
> and pa.attnum = pcons.conkey -------> the problem
>
>
>
>
>
> Thanks!!!
>
>
>
>
--
-Achilleus
From | Date | Subject | |
---|---|---|---|
Next Message | Achilleus Mantzios | 2006-06-28 15:17:00 | Re: RES: Joins between int and int[] |
Previous Message | Richard Broersma Jr | 2006-06-28 11:43:55 | Re: i need solution to this problem |