Once you developed your database in mysql there will be times when you will have to make changes. The problem is that the database may be constantly being used. While it is a good idea to prevent access to users for a breif period (1-5 minutes at most) it isn’t a good idea to make a mistake by manually entering changes since it can cause issues during the process which will increase down time. Which down time is never a good thing.
The process for doing this that I use is to create two databases on your developer unit. The first is the original database being worked on, and the second is a backup that will be used to test the batch file.
Once you have the database setup correctly, go ahead and create the batch file to test on the backup. You also want to do a mysqldump to backup the database before you do anything.
A batch file simply a text file that holds mysql commands. All you do is type in the commands in notepad, or your prefered text editor, and save it as .sql or technically whatever you want.
To run a batch file just type in the mysql client:
you can change the directory/filename as needed. This way you will quickly go through the command and reconfigure the database without causing unneeded downtime. You can even do it while the database is running, long as it doesn’t effect any current tables.
So give it a try:
Open notepad and tye:
select * from TABLE;
Save as: c:\myfirstbatch.sql
Open sql client, and access database you want to change and type:
It’s a common practice and is very useful. Also you can run these commands through an actual batch file by accessing the mysql.exe though command prompt.
For more information visit: