By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,789 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,789 IT Pros & Developers. It's quick & easy.

access to database

P: n/a
Hello
I have 2 databases on PostgreSQL, for instance base1, base2.
I connect to psql: psql -p 3333 base1
how can I access to base2 ?
for instance I wont do instruction:

insert into test(a, b)
values
select a, b
from basa2.test

of course baza2.test isn't valid on PostgreSQL - how can I do it ?
how can I get access to another database ?

sorry for my poor english :)

greet
Robert (from Poland)
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
RobertG wrote:
Hello
I have 2 databases on PostgreSQL, for instance base1, base2.
I connect to psql: psql -p 3333 base1
how can I access to base2 ?
for instance I wont do instruction:

insert into test(a, b)
values
select a, b
from basa2.test

of course baza2.test isn't valid on PostgreSQL - how can I do it ?
how can I get access to another database ?

sorry for my poor english :)

greet
Robert (from Poland)


I answered this from another news client which sometimes doesn't send
properly. So I'll answer again.

If I remember correctly (IIRC), you can't open 2 different dbases using
pgsl. You can do it by using perl DBI. I can help you do this if you
need help.

Boyd
Jul 19 '05 #2

P: n/a
On Tue, 10 Feb 2004 14:58:50 -0500, boyd (remove_) tb_moore_@bealenet_.com
wrote:
I answered this from another news client which sometimes doesn't send
properly. So I'll answer again.

If I remember correctly (IIRC), you can't open 2 different dbases using
pgsl. You can do it by using perl DBI. I can help you do this if you
need help.


I believe his other option would be to use two schemas rather than two
databases.

Cheers!

Greg

Jul 19 '05 #3

P: n/a
Hi Robert,

I've never able to log in to one database and query data from another
database in my sql queries.

But what will work is if you create one (1) database and put two distince
"schemas" in them. Read the PostgreSQL documentation about schemas. If
you went that route, you'd have one database, call it "myDB" for example.
Then, within myDB, you could create two schemas called "base1" and
"base2". If you had proper permissions on both schema's, then your query
would work. You'd have to modify your query to reference the proper
schemas with something like:

INSERT INTO base1.test(a,b)
VALUES (SELECT a, b
FROM base2.test
)

But other than using schema's like that, I don't know how to query data
from one database while logged in to another. If anyone else knows if/how
this can be done I'd love to learn.

Cheers,
w.k.
On Fri, 6 Feb 2004, RobertG wrote:
Hello
I have 2 databases on PostgreSQL, for instance base1, base2.
I connect to psql: psql -p 3333 base1
how can I access to base2 ?
for instance I wont do instruction:

insert into test(a, b)
values
select a, b
from basa2.test

of course baza2.test isn't valid on PostgreSQL - how can I do it ?
how can I get access to another database ?

sorry for my poor english :)

greet
Robert (from Poland)

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.