Sample code for Database connection

Posted on 2007-04-06
Last Modified: 2013-12-26
Hi all,

Can anyone please post sample code for database connection (Oracle or MySQL) using Shell Script.
Please add comment for the scripts, so that I can easily understand the script.

Question by:r_kar
LVL 84

Accepted Solution

ozo earned 50 total points
ID: 18873546
mysql << end #invoke mysql and send it a command
select * from database.table;
LVL 48

Assisted Solution

Tintin earned 35 total points
ID: 18879439
For Oracle, use something like:

sqlplus -s / <<EOF
select .....

Specify username/password if you don't have externally authenticated accounts.

Assisted Solution

sureshp earned 40 total points
ID: 19017035

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now