Wednesday, April 24, 2024

SQL Plus Commands

 To Run SQL Commands in Oracle. In env variables we need to set the following variables after installation.

1. ORACLE_HOME :  This the home directory of oracle client where we installed the software.



2. TNS_ADMIN :  This the path where tnsnames.ora file and sqlnet.ora file stored.  This will be ideally

$ORACLE_HOME\network\admin.



3. PATH :  This path variable should contain bin diretory of oracle. This directory contains all the utilites or tools available.

This path will be $ORACLE_HOME\bin




These three variables are necessary for oracle client setup. we will get the below error if we do not set the variables properly.



'sqlplus' is not recognized as an internal or external command,
'tnsping' is not recognized as an internal or external command,


4. Ensure that TNS Listner service is running. 


Otherwise we will get below error.

TNS-12541: TNS:no listener


Once all pre-requsites are ready we can test using tnsping

tnsping TestDB 

to check whether database available






1) To Connect as admin from SQL Plus

           Sample:   sqlplus username/password@TestDB AS SYSDBA


2) To Connect as user using sqlplus




No comments: