Re: Fwd: Need r_constraint_name

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Fwd: Need r_constraint_name
Дата
Msg-id 53CE7AFE.5060308@aklaver.com
обсуждение исходный текст
Ответ на Need r_constraint_name  (Ramesh T <rameshparnanditech@gmail.com>)
Список pgsql-general
On 07/22/2014 07:21 AM, Ramesh T wrote:
>
>
> ---------- Forwarded message ----------
> From: *Ramesh T* <rameshparnanditech@gmail.com
> <mailto:rameshparnanditech@gmail.com>>
> Date: Tue, Jul 22, 2014 at 7:50 PM
> Subject: Re: [GENERAL] Need r_constraint_name
> To: Adrian Klaver <adrian.klaver@aklaver.com
> <mailto:adrian.klaver@aklaver.com>>
>
>
> Just i'm retriving the constraint_name when  i enter child_table_name
> for inner query and that constraint name is checking
> parent_table on outer statement that constraint_name is equal then
> display the constraint name ..?but outer select is r_constraint_name

I still am not sure I am following.

If the inner query is on the child table, why are you selecting for
'PRIMARY KEY' and not 'FOREIGN KEY'?

That would sort of make sense if you where supplying the parent table
name, but again a FOREIGN KEY references a UNIQUE constraint, which may
or may not be a PRIMARY KEY. So restricting to a PRIMARY KEY will cause
you to miss relationships.

What exactly are you looking for?

>
> i think in postgres r_constraint_name is also include in the
> pg_constraints details not a seperate column in postgres for that ,if
> parent table have consraint_name same as the child table return from
> inner query that constraint_name displayed out..
>
>   my assumption..is it corect?
> from last query..
>
>
> thanks in advance..
> ramesh
>
>
> On Tue, Jul 22, 2014 at 7:18 PM, Adrian Klaver
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:
>
>     On 07/22/2014 03:12 AM, Ramesh T wrote:
>
>         thank u ,
>
>         SELECT constraint_name
>                           FROM information_schema.table___constraints AS tc
>                  WHERE     tc.table_name = p_table_name
>                        AND constraint_name IN (SELECT constraint_name
>                                                  FROM
>         information_schema.table___constraints AS tc
>                                                 WHERE     tc.table_name =
>
>         p_ref_table_name
>                                                       AND
>         tc.constraint_type =
>                                                              'PRIMARY KEY');
>
>         is this correct process same as above ..
>
>         but i want check "r_constraint_name" instead of
>         "constraint_name"  in
>         outer statement in above code..
>


--
Adrian Klaver
adrian.klaver@aklaver.com


В списке pgsql-general по дате отправления:

Предыдущее
От: Albe Laurenz
Дата:
Сообщение: Re: Referencing serial col's sequence for insert
Следующее
От: Tom Lane
Дата:
Сообщение: Re: check database integrity