この記事は約7分27秒で読むことができます。

sql oracle 12cr2 dblink

[oracle@b51cf2f967ec ~]$ find / -name tnsnames.ora -type f 2>/dev/null
/opt/oracle/product/12.2.0.1/dbhome_1/network/admin/samples/tnsnames.ora
/opt/oracle/oradata/dbconfig/ORCL/tnsnames.ora
[oracle@b51cf2f967ec ~]$ cd /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/
[oracle@b51cf2f967ec admin]$ pwd
/opt/oracle/product/12.2.0.1/dbhome_1/network/admin
[oracle@b51cf2f967ec admin]$ ll
total 4
lrwxrwxrwx. 1 oracle oinstall   46 Dec 24 14:00 listener.ora -> /opt/oracle/oradata/dbconfig/ORCL/listener.ora
drwxr-xr-x. 1 oracle dba         6 Dec 25 20:21 samples
-rw-r--r--. 1 oracle dba      1441 Aug 28  2015 shrept.lst
lrwxrwxrwx. 1 oracle oinstall   44 Dec 24 14:00 sqlnet.ora -> /opt/oracle/oradata/dbconfig/ORCL/sqlnet.ora
lrwxrwxrwx. 1 oracle oinstall   46 Dec 24 14:00 tnsnames.ora -> /opt/oracle/oradata/dbconfig/ORCL/tnsnames.ora
[oracle@b51cf2f967ec admin]$ vim tnsnames.ora


ORCL=localhost:1521/ORCL
PDB1=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB1)
)
)
RMTPDB2=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.108)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = PDB2)
)
)

[oracle@b51cf2f967ec admin]$ sqlplus sys/ORACLE_PWD@pdb1 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 23:18:50 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SYS@pdb1> grant create database link to aine;

Grant succeeded.

Elapsed: 00:00:00.05
SYS@pdb1> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@b51cf2f967ec admin]$ sqlplus aine/ORACLE_PWD@pdb1

SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 25 23:19:35 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Tue Dec 25 2018 22:39:49 +09:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

AINE@pdb1> CREATE DATABASE LINK testlink CONNECT TO aine IDENTIFIED BY ORACLE_PWD USING 'RMTPDB2';
CREATE DATABASE LINK testlink CONNECT TO aine IDENTIFIED BY ORACLE_PWD USING 'RMTPDB2'
*
ERROR at line 1:
ORA-02011: duplicate database link name

Elapsed: 00:00:00.01
AINE@pdb1> drop database link testlink;

Database link dropped.

Elapsed: 00:00:00.01
AINE@pdb1> CREATE DATABASE LINK testlink CONNECT TO aine IDENTIFIED BY ORACLE_PWD USING 'RMTPDB2';

Database link created.

Elapsed: 00:00:00.01
AINE@pdb1> select * from warehouse_mst@testlink;

WAREHOUSE_CODE           SHIPPING_PERMISSION_OVER_DAYS
------------------------ -----------------------------
w_BS98                                              25
w_DIX4                                              28
w_C5MN                                              29
w_9999                                              25

4 rows selected.

Elapsed: 00:00:00.35
AINE@pdb1>

Leave a Reply

Your email address will not be published. Required fields are marked *