【練習】創建私有的dblink


 1.創建dblink第一種方法,是在本地數據庫tnsnames.ora文件中配置了要遠程訪問的數據庫。

1.設置監聽: ①[root@host02 ~]# vi /etc/hosts 添加:【IP和名字】 192.168.206.2 host02 ②vi listener.ora: LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host02)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) ) ADR_BASE_LISTENER = /u01/app/oracle ③vi tnsnames.ora: ENMO= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host02)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ENMO) ) ) ④查看監聽狀態: [oracle@host02 ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-DEC-2016 20:37:30 Copyright (c) 1991, 2013, Oracle.  All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host02)(PORT=1521))) STATUS of the LISTENER ------------------------
Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production Start Date 01-DEC-2016 20:18:58 Uptime 0 days 0 hr. 18 min. 32 sec Trace Level               off Security ON: Local OS Authentication SNMP OFF Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora Listener Log File         /u01/app/oracle/diag/tnslsnr/host02/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host02)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "ENMO" has 1 instance(s). Instance "ENMO", status READY, has 1 handler(s) for this service... Service "ORCLXDB" has 1 instance(s). Instance "ENMO", status READY, has 1 handler(s) for this service... The command completed successfully ⑤連接到sys賦權限: SQL> conn / as sysdba Connected. SQL> grant create public database link,create database link to scott; Grant succeeded. ⑥創建dblink: SQL> create database link emp connect to scott identified by tiger using host02; Database link created.

 

2.創建dblink第二種方法,是在本地數據庫tnsnames.ora文件中沒配置要遠程訪問的數據庫。

1.設置監聽: ①[root@host02 ~]# vi /etc/hosts 添加:【IP和名字】 192.168.206.2 host02 ②vi listener.ora: LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host02)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) ) ADR_BASE_LISTENER = /u01/app/oracle ③vi tnsnames.ora: ENMO= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host02)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ENMO) ) ) ④查看監聽狀態: [oracle@host02 ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-DEC-2016 20:37:30 Copyright (c) 1991, 2013, Oracle.  All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host02)(PORT=1521))) STATUS of the LISTENER ------------------------
Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production Start Date 01-DEC-2016 20:18:58 Uptime 0 days 0 hr. 18 min. 32 sec Trace Level               off Security ON: Local OS Authentication SNMP OFF Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora Listener Log File         /u01/app/oracle/diag/tnslsnr/host02/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host02)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "ENMO" has 1 instance(s). Instance "ENMO", status READY, has 1 handler(s) for this service... Service "ORCLXDB" has 1 instance(s). Instance "ENMO", status READY, has 1 handler(s) for this service... The command completed successfully ⑤連接到sys賦權限: SQL> conn / as sysdba Connected. SQL> grant create public database link,create database link to scott; Grant succeeded. ⑥創建dblink: SQL> create database link emp connect to scott identified by tiger using 2  '(DESCRIPTION = 3 (ADDRESS = (PROTOCOL = TCP)(HOST = host02)(PORT = 1521)) 4 (CONNECT_DATA = 5 (SERVER = DEDICATED) 6 (SERVICE_NAME = ORCL) 7 ) 8 ) 9 '; Database link created.

3.創建公共的dblink
語法:create public database link emp using 。。。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM