Oracle数据库文件:listener.ora和tnsnames.ora范例

安装好Oracle数据库后,总是需要配置一些文件。
listener.ora和tnsnames.ora的文件地址:E:\oracle\product\10.2.0\db_1\network\ADMIN

listener.ora

//SinoCredit-PC是我的计算机名称,这样配置,可以直接用127.0.0.1访问本地啦。
//orcl是我的数据库安装时,填写的实例名

# listener.ora Network Configuration File: E:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
  (SID_DESC =
      (SID_NAME = orcl)
      (ORACLE_HOME = E:\oracle\product\10.2.0\db_1)
      (GLOBAL_DBNAME= orcl)
    )
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = E:\oracle\product\10.2.0\db_1)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = SinoCredit-PC)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )

tnsnames.ora

//SERVER_ORCL 配置的是我公司服务器数据库
//ORCL 配置的是我自己电脑上的数据库
# tnsnames.ora Network Configuration File: E:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.

SERVER_ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 211.88.1.111)(PORT = 1522))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = ORCL)
      (SERVICE_NAME = orcl)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

以上配置完了,就可以用plsql来访问数据库了,下面看例子:
访问本地:

这里写图片描述

访问公司服务器:

这里写图片描述

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/6d9f5588b8b61550a79b6d795b944617.html