I want to create a deployment script, somehow emulate Oracle deployment scripts, where with ¶m you can use previously declared parameters. I need to call this script for different users on different databases automatically.
For example my script should be:
USE ¶m;
DROP TABLE IF EXISTS `TEST` ;
CREATE TABLE IF NOT EXISTS `TEST` (X INT(16))
etc....
Of course ¶m is what I would have used in Oracle environment.
Thanks
Updates:
Forgot to mention that I am using a windows environment for now. I have created a batch script to call the mysql script. The easiest way I thought would be to pass to mysql 2 command: 1) use the schema I have as parameter and then call the script which will create the table regardless of the schema. Unfortunately mysql seems to understand that I want to connect to the schema X, but doesn't want to call the script.
REM param is the schema and mainsql is the script
SET param="%1"
SET mainsql="script.sql"
echo %param%
echo %mainsql%
mysql -u <user> --password=<psw> %param% "source %mainsql%;"
As far as I know you can't directly pass variables in to a MySQL script. The best you can do is set user variables in a wrapper shell script. Something like:
Adjust for actual use, of course.