Friday 2 September 2016

Local and remote connections to the database -beginner level


Connecting to the Database with SQL*Plus


About SQL*Plus
SQL*Plus is the primary command-line interface to your Oracle database. You use SQL*Plus to start up and shut down the database, set database initialization parameters, create and manage users, create and alter database objects (such as tables and indexes), insert and update data, run SQL queries, and more. Before you can submit SQL statements and commands, you must connect to the database.
With SQL*Plus, you can connect locally or remotely. Connecting locally means connecting to an Oracle database running on the same computer on which you are running SQL*Plus.
 Connecting remotely means connecting over a network to an Oracle database that is running on a remote computer. Such a database is referred to as a remote database.
The SQL*Plus executable on the local computer is provided by a full Oracle Database installation, an Oracle Client installation, or an Instant Client installation.
Connecting locally to the database:











Connecting remotely to the database:
Connecting remotely to the database requires the listener to be up and running because remote connection always goes to the listener then listener route that connection to the database.
Here i am trying to connect to the database remotley but it couldn't be able to establish the connection to the database because the listener is not started yet.


connection  failed with ORA-12541: TNS:no listener











Now i am starting the listener as stated below.



Now i am trying to connect to the database remotely with same command and this time its allowed me to establish a connection to the database. So  remote database connections always need the listener  to be up to establish a connection to the database.












Bear in mind that listener restart will not affect the existing connections, only the users try to connect to the database when the listener restart are going to rejected.