Re: Getting reference key elements in right orders

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: seiliki(at)so-net(dot)net(dot)tw
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Getting reference key elements in right orders
Date: 2010-05-17 14:09:54
Message-ID: 18483.1274105394@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

seiliki(at)so-net(dot)net(dot)tw writes:
> I need to know the match columns of referencing and referenced keys.

The query you show definitely won't match them up correctly, since that
=ANY test is not order-sensitive. What you need to do is generate the
integers from 1 to array_length(conkey) and then join on attnum =
conkey[i], rather than using =ANY. You can find some examples in the
information_schema views. (In fact, you might well find that the
information_schema views are close enough already to what you need.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message sunpeng 2010-05-17 14:31:16 which function should i invoke to create a table and insert tuples?
Previous Message Thom Brown 2010-05-17 12:28:53 Re: pg_dumpall custom format?