Re: Shema functionality in 7.3

From: Joe Conway <mail(at)joeconway(dot)com>
To: Mikael Carneholm <SA9625(at)ida(dot)utb(dot)hb(dot)se>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Shema functionality in 7.3
Date: 2002-12-02 01:53:09
Message-ID: 3DEABD05.5010804@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mikael Carneholm wrote:
> Can someone who has experience from the new 7.3 version tell me
> if
>
> SELECT tableA.foo
> FROM shema1.tableA, shema2.tableB
> WHERE tableA.bar = tableB.bar
>
> is possible thanks to the new schema functionality?

Like this?

CREATE SCHEMA schema1;
CREATE SCHEMA schema2;
CREATE TABLE schema1.table_a(bar int, foo text);
INSERT INTO schema1.table_a VALUES(1,'a');
INSERT INTO schema1.table_a VALUES(2,'b');
CREATE TABLE schema2.table_b(bar int, foo text);
INSERT INTO schema2.table_b VALUES(1,'c');
INSERT INTO schema2.table_b VALUES(2,'d');

regression=# SELECT t1.foo, t2.foo FROM schema1.table_a t1, schema2.table_b t2
WHERE t1.bar = t2.bar;
foo | foo
-----+-----
a | c
b | d
(2 rows)

> And is it possible to grant users permissions on whole schemas?

Not sure exactly what you mean, but see:

http://developer.postgresql.org/docs/postgres/sql-createschema.html
http://developer.postgresql.org/docs/postgres/sql-grant.html

> Queries like the one above is possible in Oracle, and I would really
> like to see this in PostgreSQL as well. (I guess we could call this
> feature "cross schema joins".)
>
> Note: I would not consider this as crossdb functionality, as tableA
> and tableB exist in the same database (using Oracle terms: the
> same instance), but in different shemas.
>

It's not the same as a cross db join, but the ability to use schemas is hoped
to reduce the need for that. You should look at contrib/dblink if you want to
join data across databases or servers.

HTH,

Joe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Eric B.Ridge 2002-12-02 02:20:41 Command editing with psql and OS X
Previous Message Tom Lane 2002-12-02 01:25:07 Re: how to make an 'UNLOCK'?