Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - SQL typesetting in shell script
SQL typesetting in shell script
Write a small script to do SQL, and then pipeline the output of SQL to awk, and let the awk script help you arrange the output, as follows:

mySqlScript " select * from ABC where name = ' jack ' " | \

awk '{

for(I = 1; I<= NFi++) {

printf("%s ",$ I);

}

} END { print}'

Attached is a sample mySqlScript for your reference:

if [ $# -ne 1 ]

then

echo " Usage:$ 0 \ " & lt; sql _ cmd & gt\""

/kloc-exit 0/

The ship does not bear the loading fee.

cmd=$ 1

Function sqlCmd {

login_info="$ 1 "

$ ORACLE _ HOME/bin/sqlplus-s " $ log in _ info " & lt; & lt!

Close the course

Turn off feedback

Set page size 0

Set the line size 1024

$ cmd

!

}

SqlCmd sql _ login id/SQL _ password