W
W
whats2014-04-24 13:14:37
PostgreSQL
whats, 2014-04-24 13:14:37

How to specify the name of the base in Select?

Can you please tell me how to specify the name of the database from which you want to select values ​​in the query?
There are 2 databases on 1 server, you need to form 1 large table in one of these databases in another database. Specifically, I would like to execute such a request:

INSERT into БАЗА1.foo_bar (foo_id, bar_id) ( 
  SELECT foo.id, bar.id FROM БАЗА2.foo JOIN bar 
    WHERE type = 'name' 
);

It is suitable to transfer the dump to another database and work with it there, but the possibility of such an implementation is of interest.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Lesovsky, 2014-04-24
@whats

postgresql can't query tables in different databases. use dblink or postrges_fdw.

N
nochkin, 2014-04-24
@nochkin

What's the question? The entry above is correct - "database.table"
Depending on the goals, you can also manually do it through mysqldump as an alternative.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question