Re: [GENERAL] How to access a second database - Mailing list pgsql-general

From John R Pierce
Subject Re: [GENERAL] How to access a second database
Date
Msg-id 003908b7-a928-1cef-5e5d-ab9dd5544455@hogranch.com
Whole thread Raw
In response to [GENERAL] How to access a second database  (Sherman Willden <operasopranos@gmail.com>)
Responses Re: [GENERAL] How to access a second database  (John R Pierce <pierce@hogranch.com>)
List pgsql-general
On 10/31/2017 12:15 AM, Sherman Willden wrote:
> I am trying to access a table from another database. I have the 
> permissions to create under my own login. I have performed the 
> following so far:
> sherman@sql-dev: createdb sandbox01
> sherman@sql-dev:~$ createdb sandbox02.
> After logging into sandbox02 I performed the following: sandbox02=# 
> CREATE TABLE last_names(last_name TEXT);
> sandbox02=# INSERT INTO last_names VALUES(willden);
>
> Now I think I want to use a foreign key in sandbox01. Is the following 
> how it works after logging into sandbox01?
>
> sandbox01=# CREATE TABLE first_and_last(first_name TEXT, last_name 
> FOREIGN KEY last_name REFERENCES sandbox02(last_names(last_name))
>
> and then sandbox01=# INSERT INTO first_and_last(sherman, willden);


if you're doing a lot of this, why not use two schema in the same 
database?      then its just ...schema.table...

otherwise, you need to use FDW and foreign tables.

see....
https://www.postgresql.org/docs/current/static/postgres-fdw.html



-- 
john r pierce, recycling bits in santa cruz



-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

pgsql-general by date:

Previous
From: Stanislav Ganin
Date:
Subject: Re: [GENERAL] How to access a second database
Next
From: John R Pierce
Date:
Subject: Re: [GENERAL] How to access a second database