Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDU2k-00071R-QS for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Aug 2021 15:51:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mDU2i-00038k-39 for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Aug 2021 15:51:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDU2h-00033t-SE for pgsql-bugs@lists.postgresql.org; Tue, 10 Aug 2021 15:51:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDU2X-0004BO-T2 for pgsql-bugs@lists.postgresql.org; Tue, 10 Aug 2021 15:51:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 17AFpNeq3788090; Tue, 10 Aug 2021 11:51:25 -0400 From: Tom Lane To: Alex Zeng cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: information_schema.constraint_column_usage shows wrong table name In-reply-to: References: Comments: In-reply-to Alex Zeng message dated "Tue, 10 Aug 2021 02:57:00 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3788088.1628610683.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 10 Aug 2021 11:51:23 -0400 Message-ID: <3788089.1628610683@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alex Zeng writes: > When creating a constraint from table A to table B, the table name and c= olumn name in information_schema.constraint_column_usage shows table B. T= hat 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