Обсуждение: triggers/functions across databases

Поиск
Список
Период
Сортировка

triggers/functions across databases

От
"Eric Jones"
Дата:
We are migrating from Informix to Postgres 7.4.7 and are having a
difficult time finding if postgres can insert/update tables across
different databases. Namely using functions/triggers when an
update/insert is performed on a table it updates/inserts in a table on a
different database. Informix can do this with no problem but we were
wondering if there is an easy way for postgres to do this. I've searched
numerous sites and found vague answers. Thanks in advance.

Eric Jones


Re: triggers/functions across databases

От
Scott Marlowe
Дата:
On Wed, 2005-05-25 at 07:08, Eric Jones wrote:
> We are migrating from Informix to Postgres 7.4.7 and are having a
> difficult time finding if postgres can insert/update tables across
> different databases. Namely using functions/triggers when an
> update/insert is performed on a table it updates/inserts in a table on a
> different database. Informix can do this with no problem but we were
> wondering if there is an easy way for postgres to do this. I've searched
> numerous sites and found vague answers. Thanks in advance.

Could you solve this problem using schemas in one database?  OR do you
need the data to be in two physically separate locations?  If so, you
might be better off using listen / notify between the two databases, or
using an external program to begin transactions in both places and
commit or roll them back together.

Re: triggers/functions across databases

От
Richard Huxton
Дата:
Eric Jones wrote:
> We are migrating from Informix to Postgres 7.4.7 and are having a
> difficult time finding if postgres can insert/update tables across
> different databases. Namely using functions/triggers when an
> update/insert is performed on a table it updates/inserts in a table on a
> different database. Informix can do this with no problem but we were
> wondering if there is an easy way for postgres to do this. I've searched
> numerous sites and found vague answers. Thanks in advance.

If in doubt, check the manuals or contact the list.

The short answer is "no" - you can query across schemas but not across
databases.

The long answer is "maybe" - check the contrib/dblink package (in the
source distribution). That can query another database on the same or
different machine.

--
   Richard Huxton
   Archonet Ltd

Re: triggers/functions across databases

От
"Joshua D. Drake"
Дата:
Eric Jones wrote:
> We are migrating from Informix to Postgres 7.4.7 and are having a
> difficult time finding if postgres can insert/update tables across
> different databases. Namely using functions/triggers when an
> update/insert is performed on a table it updates/inserts in a table on a
> different database. Informix can do this with no problem but we were
> wondering if there is an easy way for postgres to do this. I've searched
> numerous sites and found vague answers. Thanks in advance.

If you have databases that are dependent on each others data you should
probably move those databases into a new schema within one database...

See the create schema command.

Otherwise you could use dblink but it would not be my suggestion.

Sincerely,

Joshua D. Drake


>
> Eric Jones
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster


--
Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240
PostgreSQL Replication, Consulting, Custom Programming, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/

Re: triggers/functions across databases

От
Mike Nolan
Дата:
> If you have databases that are dependent on each others data you should
> probably move those databases into a new schema within one database...

That's a non-trivial task, especially if some of the tables in the
two databases have the same name.
--
Mike Nolan

Re: triggers/functions across databases

От
"Joshua D. Drake"
Дата:
Mike Nolan wrote:
>>If you have databases that are dependent on each others data you should
>>probably move those databases into a new schema within one database...
>
>
> That's a non-trivial task, especially if some of the tables in the
> two databases have the same name.

Migrating from one database to another database is a non trivial task as
a whole :)

> --
> Mike Nolan


--
Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240
PostgreSQL Replication, Consulting, Custom Programming, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/