pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron Peterson <ron.peterson@yellowbank.com>
To: pgsql-sql@postgresql.org
Subject: finding foreign keys
Date: Tue, 23 Jan 2001 16:50:25 -0500
Message-ID: <3A6DFCA1.248D0979@yellowbank.com> (raw)

Can anyone suggest a more elegant way of finding foreign keys than
parsing the tgargs value returned by this query?  I'd really rather do
pure SQL, sans string parsing, if possible.

------------------------------------------------------------------------
-- Find tables and foreign keys

CREATE VIEW foreignkeysa AS
	SELECT	t.oid as toid,
		c1.relname AS relid,
		c2.relname AS constrrelid,
		t.tgargs AS tgargs

	FROM	pg_trigger AS t,
		pg_class AS c1,
		pg_class AS c2

	WHERE	t.tgrelid=c1.oid AND
		t.tgconstrrelid=c2.oid AND
		t.tgfoid=1644;
------------------------------------------------------------------------

-Ron-



Message-ID: <3A6DFCA1.248D0979@yellowbank.com>
Permalink:  ../3A6DFCA1.248D0979@yellowbank.com/
Also on:    postgresql.org/message-id/3A6DFCA1.248D0979@yellowbank.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: ron.peterson@yellowbank.com
  Subject: Re: finding foreign keys
  In-Reply-To: <3A6DFCA1.248D0979@yellowbank.com>
  References: <3A6DFCA1.248D0979@yellowbank.com>

* 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