Re: [HACKERS] SQL queries accessing tables in more than one db - Mailing list pgsql-hackers

From ocie@paracel.com
Subject Re: [HACKERS] SQL queries accessing tables in more than one db
Date
Msg-id 9806222324.AA08631@dolomite.paracel.com
Whole thread Raw
In response to SQL queries accessing tables in more than one db  (De Clarke <de@ucolick.org>)
List pgsql-hackers
De Clarke wrote:
>
> RE:  ability to access tables from different DB in same SQL query

[snip]

> Here's the point, then.  The user's temp table wants to live in
> a DB with generous permissions:  ordinary users can create and
> delete tables!  But the original telemetry data want to live in
> a very protected DB where users absolutely cannot mess with the
> original tables OR go creating tables of their own that compete
> with the originals for storage space.
>
>     select * into sandbox.guest.DMyn_de897082595_D1 from
>         telem.dbo.hires_Log_1 where logstamp between
>         'Jun 19 1998 03:00' and 'Jun 19 1988 08:00'

A couple of comments on this.  Sybase does have quite an elegant
system for this <db>.<owner>.<table>.<column> for simple queries,
table can be omitted, when not ambiguous, user can be omitted and the
full form can be used in all queries if the permissions are right.  So
you could just as easily say:

select * from telem..hires_Log_1 where logstamp=sandbox..table1.timestamp

Now we could take it one step further and put the name of the database
server before all of this, so you could say:

select * from office1.sales..saleslog,
              office2.sales..saleslog,
... etc

I wouldn't vouch for performance in this case though.

Ocie

pgsql-hackers by date:

Previous
From: De Clarke
Date:
Subject: SQL queries accessing tables in more than one db
Next
From: dg@illustra.com (David Gould)
Date:
Subject: Re: [HACKERS] Problem after removal of exec(), help