pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alex Zeng <Alex.Zeng@datam.co.nz>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: information_schema.constraint_column_usage shows wrong table name
Date: Tue, 10 Aug 2021 11:51:23 -0400
Message-ID: <3788089.1628610683@sss.pgh.pa.us> (raw)
In-Reply-To: <SY4PR01MB7201EE307A0E5F28C4BF26B8B7F79@SY4PR01MB7201.ausprd01.prod.outlook.com>
References: <SY4PR01MB7201EE307A0E5F28C4BF26B8B7F79@SY4PR01MB7201.ausprd01.prod.outlook.com>

Alex Zeng <Alex.Zeng@datam.co.nz> writes:
> When creating a constraint from table A to table B, the table name and column name in information_schema.constraint_column_usage  shows table B. That makes impossible to check whether a constraint exists as we can have a constraint from table C to B and they will have same value in information_schema.constraint_column_usage.

The SQL standard says the purpose of this view is to

    Identify the columns used by referential constraints, unique
    constraints, check constraints, and assertions defined in this catalog
    and owned by a given user or role.

so I think the view is showing the column name it is supposed to,
ie the referenced column name not the referencing column name.
The key_column_usage view might help you with the other thing.

			regards, tom lane





view thread (3+ messages)

Message-ID: <3788089.1628610683@sss.pgh.pa.us>
Permalink:  ../3788089.1628610683@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3788089.1628610683@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Alex.Zeng@datam.co.nz, pgsql-bugs@lists.postgresql.org
  Subject: Re: information_schema.constraint_column_usage shows wrong table name
  In-Reply-To: <3788089.1628610683@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox