tnsname.ora
时间: 2023-12-17 11:05:52 浏览: 29
Tnsnames.ora is a configuration file used by Oracle Net Services to connect to Oracle databases. It contains the network service names that are used to connect to a database over a network. The file is usually located in the $ORACLE_HOME/network/admin directory.
The syntax of tnsnames.ora file is as follows:
```
net_service_name =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = port))
)
(CONNECT_DATA =
(SERVICE_NAME = service_name)
)
)
```
Where:
- `net_service_name` is the name of the network service that you want to use to connect to the database.
- `hostname` is the name of the machine where the database is located.
- `port` is the port number that the database listener is listening on.
- `service_name` is the name of the database service that you want to connect to.
You can have multiple net service names defined in the tnsnames.ora file, each pointing to a different database or instance. This allows you to easily switch between different databases without having to change your application code.