Thread: Joins between int and int[]

Joins between int and int[]

From
"Rodrigo Sakai"
Date:

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

 

 

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