pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Meyland Andersen <jma@agile.dk>
To: pgsql-sql@postgresql.org
Subject: Related tables to a view
Date: Mon, 25 Dec 2006 22:52:03 +0100 (CET)
Message-ID: <1404.62.66.218.59.1167083523.squirrel@mail.agile.dk> (raw)

Hi

I need a function which are able to return the underlying tables to a view.

If I have a view which is a selection from field1 and field2 from table1
and field1 and field2 from table2.

How can I make a selection which returns the relation for the fields in a
way so I am able to se which field belongs to which table.

SELECT * FROM pg_views WHERE viewname='TestView' will return the schema
and the definition for me.

SELECT * FROM pg_class WHERE relname = 'TestView' will return some oids etc.

SELECT * FROM pg_attribute JOIN pg_class ON attrelid = pg_class.oid AND
pg_class.relname='TestView' will return the fields including oids etc.

But I just cant find out how to find the tables for each field.

I hope someone are able to help me with this problem.

Regards

Jan Andersen




view thread (6+ messages)  latest in thread

Message-ID: <1404.62.66.218.59.1167083523.squirrel@mail.agile.dk>
Permalink:  ../1404.62.66.218.59.1167083523.squirrel@mail.agile.dk/
Also on:    postgresql.org/message-id/1404.62.66.218.59.1167083523.squirrel@mail.agile.dk

 · 

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-sql@postgresql.org
  Cc: jma@agile.dk
  Subject: Re: Related tables to a view
  In-Reply-To: <1404.62.66.218.59.1167083523.squirrel@mail.agile.dk>

* 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