Oracle客户端连接数据库配置

时间:2024-01-21 09:46:10

配置文件和路径

  • 配置文件:tnsnames.ora
  • 默认路径:%ORACLE_HOME%\network\admin\tnsnames.ora%ORACLE_HOME%通常在环境变量中使用。
  • 我的路径为:C:\Program Files (x86)\Oracle\Instant Client\network\admin\tnsnames.or

配置文件如下:

# tnsnames.ora Network Configuration File.
# Generated by Oracle configuration tools.

# Sample:
#DatabaseName =   
#  (DESCRIPTION =
#    (ADDRESS_LIST =
#      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))  
#    )
#    (CONNECT_DATA =
#      (SERVER = DEDICATED)
#      (SERVICE_NAME = ServiceName)
#      (INSTANCE_NAME = InstanceName)                     
#    )
#  )

# Modify the following content to fit your own needs.
DummyDatabase =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = DummyService)
    )
  )


pcidata_hce =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.20.10.10)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = devorcl)
    )
  )
  
FM_DEV=
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.20.10.223)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = testorcl)
    )
  )

hceorcl =                                                               //数据库名称自定义文中唯一值
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.20.10.123)(PORT = 1521))     //数据库IP及端口号
    (CONNECT_DATA =
      (SID =orcl)                                                       //实例名
    )
  )
pdatatest =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.20.10.182)(PORT = 1521))
    (CONNECT_DATA =
      (SID =pdatatest)
    )
  )

162ora =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.20.10.162)(PORT = 1521))
    (CONNECT_DATA =
      (SID =pdjgorcl)
    )
  )

 这样就可以通过pl/sql developer连接了。