Connecting to Oracle Database Instance Using SQL*Plus – A Beginner’s Guide
What is SQL*Plus?
SQL*Plus is a command-line tool provided by Oracle for interacting with the database. It allows you to execute SQL and PL/SQL commands, run scripts, and manage database connections.
Why You Need to Configure a Connection?
To connect your Oracle client to a remote or local Oracle instance, you need a valid configuration that maps your connection to the database. This involves setting up the tnsnames.ora
file and having the correct service name, host, and port details.
Step 1: Locate or Create the tnsnames.ora File
$ORACLE_HOME/network/admin
C:\oracle\product\version\network\admin\
Step 2: Sample tnsnames.ora Entry
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rh-server)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
Explanation:
Entry | Description |
---|---|
ORCL | Net service name (you can call it anything like ron ) |
HOST | IP or hostname of the server |
PORT | Listener port (default: 1521) |
SERVICE_NAME | Database instance name (e.g., orcl , xe , prod ) |
Pro Tip: Custom Net Service Names
sqlplus username/password@ron
Step 3: Connect Using SQL*Plus
sqlplus plsql_user/password@orcl
Connected to:
Oracle Database 21c Enterprise Edition ...
SQL>
Step 4: Test Your Connection Using TNSPING
tnsping orcl
Used TNSNAMES adapter to resolve the alias
Attempting to contact...
OK (40 msec)
TNS-03505: Failed to resolve name
Step 5: Test via Net Manager
Oracle provides tools like Net Manager or Net Configuration Assistant to visually configure your connection. These allow you to test the connection, although the default test credentials (SCOTT/TIGER) may not exist in newer databases. Even if the login fails, a connection attempt means the network setup works.
Hosts File (Optional for IP Mapping)
If you don’t have a DNS system, add this to your local hosts file:
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 rh-server
When Should You Use This Method?
Setting up client-to-server connections in Oracle environments
Working in enterprise networks without graphical tools
Automating connections for batch or cron jobs
Testing new instance setups and listener configurations
AmantPoint Exclusive Learning Series
© 2025 AmantPoint. All rights reserved. Educational content for developers and learners.