Postgres can not be directly accessed between different databases, such as database Test1 and test2, each database has a table of TableA; I am using the operating system Win8.1,postgres version 9.3.6; Access to Postgres using the PGADMINIII tool;
Create a TableA in two databases (TEST1,TEST2) respectively;
Test1 database creates TableA and inserts data:
CREATE TABLE TableA (ID int,name varchar (10));
INSERT INTO TableA values
(1, ' a '), (2, ' B ');
Test2 database creates TableA and inserts data:
CREATE TABLE TableA (ID int,name varchar (10));
INSERT INTO TableA values
(1, ' C '), (2, ' d ');
accessing tables in Test1 and Test2 databases from the Test1 database, respectively
The reported error is: Database Association not implemented: "Test2.public.tablea" SQL Status: 0a000
I wrote the table above according to: Database. Schema. Table name
The schema in SQL Server is dbo, accessed using SELECT * from Test2.dbo.tablea; personal feeling pgadminiii and ssms are similar, or each Database window management tool is similar, Mysql Workbench is similar.
Now take a screenshot and see if the Test1 data can test2 the number of functions below the database schema (all 0)
Open the SQL window in the Test1 database and enter create extension dblink;
Then refresh on the test database, you will see the pattern-public--function, the number in parentheses is not 0
Then make the connection and query in the SQL window
Select Dblink_connect (' T_connect ', ' dbname=test2 host=localhost port=5432 user=postgres password=postgres ');
SELECT * from Dblink (' T_connect ', ' select * from TableA ') as T2 (ID int,name varchar (10));
The above SELECT statement is actually taking advantage of the Dblink (Text,text) and Dblink_connect (Text,text) functions
The tables in the two database are connected in a similar form, or in the SQL window of the TEST1 database
Select A.*,b.name from TableA a inner join
(SELECT * from Dblink (' T_connect ', ' select * from TableA ') as T2 (ID int,name varchar ()) b
On A.id=b.id
is to take this query select * from Dblink (' T_connect ', ' select * from TableA ') as T2 (ID int,name varchar (10)) as a table.
Very similar to SQL Server in a linked server, query the linked server SQL, before the essay should have written SQL Server link MySQL, through ssms query MySQL data.
Postgres before I did not contact, but the work needs to use Postgres, there are application needs, always to solve!
Postgres access between different databases