Skip to content

TNS connection string format

A TNS connection string format (also known as a connect descriptor) defines the network route and service name required to establish a connection to an [[Oracle database]]. It typically consists of three main components: an ADDRESS_LIST, CONNECT_DATA, and configuration options such as LOAD_BALANCE or FAILOVER.^[600-developer-database-oracle-oracle-db-link.md]

Syntax Structure

The string is constructed using a nested list of parameters enclosed in parentheses.^[600-developer-database-oracle-oracle-db-link.md]

  • ADDRESS: Defines the protocol, host, and port for the database listener. Common settings include PROTOCOL=TCP, a specific HOST (IP or hostname), and PORT (default is 1521).^[600-developer-database-oracle-oracle-db-link.md]
  • CONNECT_DATA: Specifies the specific database service to connect to, typically using the SERVICE_NAME parameter.^[600-developer-database-oracle-oracle-db-link.md]

Usage

This format is primarily used in two scenarios: defining a USING clause within a CREATE DATABASE LINK statement, or manually configuring connection details in client software like tnsnames.ora.^[600-developer-database-oracle-oracle-db-link.md]

Example

The following is an example of a TNS connection string used to create a database link named mypaycenter:^[600-developer-database-oracle-oracle-db-link.md]

'(DESCRIPTION=
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.140.0.1)(PORT = 1521))
  )
  (CONNECT_DATA = (SERVICE_NAME = myPay))
)'
  • [[Oracle database]]
  • [[SQL]]
  • [[Database link]]

Sources

^[600-developer-database-oracle-oracle-db-link.md]