Thursday, September 26, 2019

Unix Shell Script to connect Oracle database



[oracle@ODIGettingStarted practice]$ vi conoracle.sh
[oracle@ODIGettingStarted practice]$ cat conoracle.sh
user="scott"
pass="tiger"
sqlplus -s $user/$pass@ORCL <<EOF
select * from student;
exit;
EOF
[oracle@ODIGettingStarted practice]$ sh conoracle.sh

ID NAME
---------- --------------------
2 sekhar
1 raj

[oracle@ODIGettingStarted practice]$


Verifying Result from Database:

[oracle@ODIGettingStarted ~]$ sqlplus scott/tiger

SQL*Plus: Release 11.2.0.4.0 Production on Thu Sep 26 23:42:26 2019

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from student;

ID NAME
---------- --------------------
2 sekhar
1 raj

SQL> 

No comments:

Post a Comment