Tuesday, May 28, 2013

-bash: sqlplus: command not found - error while connecting sqlplus through Putty (VMWARE)

Oracle 10g express edition for Linux 


login as: rajani
rajani@192.168.1.172's password:
Last login: Sun Apr 21 17:59:22 2013 from 192.168.1.18
[rajani@localhost ~]# sqlplus
-bash: sqlplus: command not found
[rajani@localhost ~]#


1st Method by finding the oracle enivironment file :

Find the oracle_env.sh file

find / -name oracle_env.sh -print

[rajani@localhost ~]$ find / -name oracle_env.sh -print

/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh

Then 

[rajani@localhost ~]$ source /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh

[rajani@localhost ~]$ sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 28 00:04:44 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Enter user-name: hr
Enter password:

Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

SQL>

2nd Method by editing the .bash_profile file 


Step1. You need to find oracle home directory

find / -name sqlplus -print


On the output of this command you should have some lines telling you where are the sqlplus command.
By example, imagine that the output has something like this:

/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/sqlplus
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/sqlplus

Then your  ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server (FYI only) 

Step2 : (only perform this step) 

edit the .bash_profile as follows

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
export ORACLE_SID=XE
export PATH=$PATH:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin
export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server

Then save it ESC:wq

Then execute the .bash_profile (./.bash_profile ) by pre-setting  permission to 777. 

Come out of putty and login again.

login as: rajani
rajani@192.168.1.172's password:
Last login: Tue May 28 00:03:12 2013 from 192.168.1.18
[rajani@localhost ~]$ sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 28 00:08:08 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Enter user-name: hr/hr

Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production


Hope this helps.

Cheers 

Rajani

No comments:

Post a Comment