← Back to team overview

maria-discuss team mailing list archive

New Question: Executing a command file from within a command file?

 

Hello,

A new question has been asked in "mysql client" by JohnD:
--------------------------------
I have a bunch of things I'd like to execute one after the other. A simple example would be:
- drop table x;
- drop table y;
- create table y by executing create_table_y.sql
- create table x by executing create_table_x.sql

With the mysql command line, I can execute "drop table x;", and I can execute a SQL script with -e "source create_table_x.sql".

But what is the good way to bundle all these together into a script which will do all the actions? The only way I can think of is to create a batch file which will call out to mysql for each action. And pass the password as an argument to the batch file. Like this:
   mysql -u root -p mypassword -e "drop table x;"   
   mysql -u root -p mypassword -e "drop table y;"
   mysql -u root -p mypassword -e "source create_table_y.sql"
   mysql -u root -p mypassword -e "source create_table_x.sql"

But this seems fairly clunky. Is there a better, or even best practice?

John D.
--------------------------------

To view or answer this question please visit: http://kb.askmonty.org/en/executing-a-command-file-from-within-a-command-file/