zoukankan      html  css  js  c++  java
  • 【练习】创建私有的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 。。。

  • 相关阅读:
    android中接口和抽象类的区别
    最靠谱的禁止ViewPager滑动方法
    Android Studio 自定义属性,命名空间
    代码设置Android EditText的相关问题。输入长度maxLength
    关于Android中,保留小数点后两位的方式
    Android的线程使用来更新UI----Thread、Handler、Looper、TimerTask等
    既然安卓免费,那 Google 是靠什么赚钱的?
    android viewconfiguration
    Android中实现为TextView添加多个可点击的文本
    Textview解析带图片的html示例
  • 原文地址:https://www.cnblogs.com/tomatoes-/p/6130634.html
Copyright © 2011-2022 走看看