Re: [GENERAL] How to access a second database

Поиск
Список
Период
Сортировка
От Stanislav Ganin
Тема Re: [GENERAL] How to access a second database
Дата
Msg-id BN3PR0501MB1378F14B38925AC75F3062DDB35E0@BN3PR0501MB1378.namprd05.prod.outlook.com
обсуждение исходный текст
Ответ на [GENERAL] How to access a second database  (Sherman Willden <operasopranos@gmail.com>)
Список pgsql-general

Hello Sherman,

 

You cannot cross reference databases like this in PG. You should re-think the schema you are going to use.

Check this line from the documentation (https://www.postgresql.org/docs/current/static/ddl-schemas.html):

PostgreSQL database cluster contains one or more named databases. Users and groups of users are shared across the entire cluster, but no other data is shared across databases. Any given client connection to the server can access only the data in a single database, the one specified in the connection request.”

 

Regards,

Stanislav

 

From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Sherman Willden
Sent: Tuesday, October 31, 2017 9:15 AM
To: pgsql-general@postgresql.org
Subject: [GENERAL] How to access a second database

 

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);

 

Thank you;

Sherman

В списке pgsql-general по дате отправления:

Предыдущее
От: Sherman Willden
Дата:
Сообщение: [GENERAL] How to access a second database
Следующее
От: John R Pierce
Дата:
Сообщение: Re: [GENERAL] How to access a second database