Re: Fwd: Need r_constraint_name

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Ramesh T <rameshparnanditech(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Fwd: Need r_constraint_name
Date: 2014-07-22 14:53:50
Message-ID: 53CE7AFE.5060308@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/22/2014 07:21 AM, Ramesh T wrote:
>
>
> ---------- Forwarded message ----------
> From: *Ramesh T* <rameshparnanditech(at)gmail(dot)com
> <mailto:rameshparnanditech(at)gmail(dot)com>>
> Date: Tue, Jul 22, 2014 at 7:50 PM
> Subject: Re: [GENERAL] Need r_constraint_name
> To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com
> <mailto:adrian(dot)klaver(at)aklaver(dot)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(dot)klaver(at)aklaver(dot)com <mailto:adrian(dot)klaver(at)aklaver(dot)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(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2014-07-22 14:58:40 Re: check database integrity
Previous Message Albe Laurenz 2014-07-22 14:53:16 Re: Referencing serial col's sequence for insert