Connecting to a Database Through the Network- Creating a Database

Once the listener has been configured and started, you can test remote connectivity from a SQL*Plus client, as follows:

$ sqlplus user/pass@’server:port/service_name’

In the next line of code, the user and password are system/PassFun23c, connecting the mmfalcon server, port 1521, to a database named mmdb23c:

$ sqlplus system/PassFun23c@’mmfalcon:1521/mmdb23c’

This example demonstrates what is known as the easy connect naming method of connecting to a database. It’s easy because it doesn’t rely on any setup files or utilities. The only information you need to know is username, password, server, port, and service name (SID).

Another common connection method is local naming. This method relies on

connection information in the ORACLE_HOME/network/admin/tnsnames.ora file. In this example, the tnsnames.ora file is edited, and the following Transparent Network Substrate (TNS) (Oracle’s network architecture) entry is added:

Now, from the OS command line, you establish a connection by referencing the mmdb23c TNS information that was placed in the tnsnames.ora file:

$ sqlplus system/PassFun23c@mmdb23c

This connection method is local because it relies on a local client copy of the tnsnames.ora file to determine the Oracle Net connection details. By default, SQL*Plus inspects the directory defined by the TNS_ADMIN variable for a file named tnsnames.ora. If not found, then the directory defined by ORACLE_HOME/network/admin is searched.

If the tnsnames.ora file is found, and if it contains the alias specified in the SQL*Plus connection string (in this example, mmdb23c), then the connection details are derived from the entry in the tnsnames.ora file.

Tip You can use the netca utility to create a tnsnames.ora file. start the utility and choose the Local net service name Configuration option.You will be prompted for input, such as the siD, hostname, and port.

Leave a Reply

Your email address will not be published. Required fields are marked *