Software Outsourcing, Offshore Software Development, Offshore Outsourcing Services, IT Outsourcing, Offshore Development
MySQL manual Offshore Software Outsourcing and Programming, IT Outsourcing Offshore Software Development  
Call Us Today: 1-800-678-9001
Offshore Software Outsourcing and Programming, IT Outsourcing Offshore Software Development

Home / Technical Support / MySQL

Key Offerings:

B2B and B2C E-Business Solutions

Offshore Software Development Outsourcing

Strategic Consulting

Offshore Software Outsourcing

About ALTOROS: ALTOROS Systems is headquartered in Tampa, Florida and maintains an office near Boston, Massachusetts and technology development center in Belarus and Russia. ALTOROS specializes on providing value-added e-commerce and web-based software development and offshore software outsourcing services to emerging enterprises helping them successfully plan and implement business initiatives.

Contact Us for more information.

Node: Batch mode, Next: Twin, Prev: Examples, Up: Tutorial
Using mysql in Batch Mode
 
In the previous sections, you used mysql interactively to enter queries and view the results.  You can also run mysql in batch mode.  To do this, put the commands you want to run in a file, then tell mysql to read its input from the file:
 
shell> mysql < batch-file
 
If you are running mysql under windows and have some special characters in the file that causes problems, you can do:
 
dos> mysql -e "source batch-file"
 
If you need to specify connection parameters on the command-line, the command might look like this:
 
shell> mysql -h host -u user -p < batch-file
Enter password: ********
 
When you use mysql this way, you are creating a script file, then executing the script.
 
If you want the script to continue even if you have errors, you should use the --force command-line option.
 
Why use a script?  Here are a few reasons:
 
      ·      If you run a query repeatedly (say, every day or every week), making it a script allows you to avoid retyping it each time you execute it.
 
      ·      You can generate new queries from existing ones that are similar by copying and editing script files.
 
      ·      Batch mode can also be useful while you're developing a query, particularly for multiple-line commands or multiple-statement sequences of commands.  If you make a mistake, you don't have to retype everything.  Just edit your script to correct the error, then tell mysql to execute it again.
 
      ·      If you have a query that produces a lot of output, you can run the output through a pager rather than watching it scroll off the top of your screen:
 
shell> mysql < batch-file | more
 
      ·      You can catch the output in a file for further processing:
 
shell> mysql < batch-file > mysql.out
 
      ·      You can distribute your script to other people so they can run the commands, too.
 
      ·      Some situations do not allow for interactive use, for example, when you run a query from a cron job.  In this case, you must use batch mode.
 
The default output format is different (more concise) when you run mysql in batch mode than when you use it interactively.  For example, the output of SELECT DISTINCT species FROM pet looks like this when run interactively:
 
+---------+
| species |
+---------+
| bird    |
| cat     |
| dog     |
| hamster |
| snake   |
+---------+
 
But like this when run in batch mode:
 
species
bird
cat
dog
hamster
snake
 
If you want to get the interactive output format in batch mode, use mysql -t.  To echo to the output the commands that are executed, use mysql -vvv.
 
You can also use scripts in the mysql command-line prompt by using the source command:
 
mysql> source filename;
 
Offshore Software Outsourcing company Russia Florida Massachusetts Boston Belarus, Offshore Software Development Services, Offshore Programming and IT OutsourcingOffshore Development, Programming  Services, Tampa FL Russia, E-commerce, Database, CRM, Financial Insurance Health Care Real EstateOffshore Software Development Services, Software Outsourcing Russia
HOME PAGE, Offshore Software Outsourcing Company, offshore IT outsourcing services, offshore 
software development Russia Massachusetts Florida New York CT VT RI software development