PostgreSQL, how to extract all the possible couples of a primary key in a table?
Sounds like a simple cross join: 

select a.id, b.id
from input_table a
  cross join input_table b
where a.id &lt;&gt; b.id;