MySQL Forums
Forum List  »  Oracle

sqlplus vs mysql command line tool
Posted by: scott.storck
Date: June 29, 2004 01:45AM


I am currently trying to migrate a simple web based application from oracle to mysql.
To administer the database on oracle, I used shell scripts calling sqlplus to run sql scripts. (sqlplus is a sql shell , simular to the mysql sql shell)
With sqlplus, you can pass parameters to your sql.

sqlplus login/password@database @commands.sql 345 654 342
in the exaple , "commands.sql" is the text file containing sql, and "345 654 342" are the values I am passing to the "&1 &2 &3" variables respectivily.

Therefore I currently have a script which does:
# call setuserpasswd.sql
# variable 1 = username
# variable 2 = new password
sqlplus tiger/*******@tigercity @/path/to/my/sql/setuserpasswd.sql $1 $2

the contents of the file setuserpasswd.sql:
update users set passwd='&2' where username='&1';

if I call this from the unix shell: johndoe somepassword

the following sql gets executed:
update users set passwd='somepassword' where username='johndoe';

I have searched for something compairable with the mysql sql shell, but I didn't find anything.

Scott Storck

Options: ReplyQuote

Written By
sqlplus vs mysql command line tool
June 29, 2004 01:45AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.