Re: [HACKERS] SQL queries accessing tables in more than one db

From: ocie(at)paracel(dot)com
To: de(at)ucolick(dot)org (De Clarke)
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] SQL queries accessing tables in more than one db
Date: 1998-06-22 23:24:39
Message-ID: 9806222324.AA08631@dolomite.paracel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Gould 1998-06-23 01:51:39 Re: [HACKERS] Problem after removal of exec(), help
Previous Message Brett_McMahon 1998-06-22 23:19:10