Create a synonym for a table in a database hosted on another server

In oracle, if another database is on the same server, I did the following to create a synonym

CREATE SYNONYM synonymName FOR databaseName.schema.table;

What should I do to create a synonym for tables in a database hosted on another server so that I can provide credentials to connect to the server.

I need this for both oracle and netezza.

Edit: while trying (for Oracle), referring to the answer below, I received a syntax error when the remote link contains an ip address or '-' in the link name. eg.

CREATE PUBLIC DATABASE LINK abc-def.xyz.com CONNECT TO user IDENTIFIED BY pw USING 'databaseName';
+5
source share
2 answers

For Oracle, you must create a database link for the remote database:

CREATE PUBLIC DATABASE LINK rmt CONNECT TO user IDENTIFIED BY pw USING 'remotedb';

Then create a synonym:

CREATE SYNONYM syn FOR schema.table@rmt;

Then just select SELECT x, y, z FROM syn;

netezza.

EDIT:

"-" .

IP- , . , - , IP- ? . IP- .

+8

@DCookie

.

CREATE PUBLIC DATABASE LINK rmt CONNECT TO user IDENTIFIED BY pw USING 
'HOST_NAME:PORT/SERVICE_NAME_SID'
0

All Articles