Thread: Creating views (Multiple Databases)

Creating views (Multiple Databases)

From
Benjamin Arai
Date:
Hi,

Is it possible to create a view from two different database tables? 

Re: Creating views (Multiple Databases)

From
Michael Glaesemann
Date:
On Feb 2, 2006, at 16:05 , Benjamin Arai wrote:

> Is it possible to create a view from two different database tables?

Yes. You can create a view out of any query (i.e., SELECT statement).
For example,

CREATE VIEW companies__members__view AS
SELECT company.company_name, member.given_name, member.family_name,
FROM companies
JOIN companies__members USING (company_id)
JOIN members USING (member_id);

Here's a couple of links to some of the documentation on views:
http://www.postgresql.org/docs/current/interactive/sql-createview.html
http://www.postgresql.org/docs/8.1/interactive/tutorial-views.html

Between different *databases* is another issue. You'll need to look
at something like dblink (in contrib). If you think you might be
doing this a lot you might want to consider making one database,
separating out different sections in different schemas as necessary.

Hope this helps.

Michael Glaesemann
grzm myrealbox com




Re: Creating views (Multiple Databases)

From
"A. Kretschmer"
Date:
am  01.02.2006, um 23:05:43 -0800 mailte Benjamin Arai folgendes:
> Hi,
>
> Is it possible to create a view from two different database tables? --

Yes, with dblink

08:17 < akretschmer> ??dblink
08:17 < rtfm_please> For information about dblink
08:17 < rtfm_please> see http://developer.postgresql.org/cvsweb.cgi/pgsql/contrib/dblink/
08:17 < rtfm_please> or http://pgfoundry.org/projects/dblink-tds/


HTH, Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47215,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===