<< previous page   --   table of contents   --   next page >>
| | | | | | | |
  • Return to Table of Contents
  • Table of Contents

    1. General Information
    2. MySQL Installation
    3. Tutorial Introduction
    4. Database Administration
    5. MySQL Optimisation
    6. MySQL Language Reference
    7. MySQL Table Types
    8. MySQL APIs
    9. Extending MySQL

    Chapter 3:  Tutorial Introduction 175 3.6  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 le, then tell mysql to read its input from the le: shell> mysql < batch-file If you are running mysql under windows and have some special characters in the le 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 le, 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 les.    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 o the top of your screen: shell> mysql < batch-file | more    You can catch the output in a le 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 di erent (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 |
     

    Customer Support CentreMySQL Reference Manual

    Web Hosting Services
    UNIX WEB HOSTING
    SUPPORT & FAQ's
    TERMS OF USE
    Domain Services
    DOMAIN REGISTRATION
    MANAGE YOUR ACCOUNT
    SUPPORT & FAQ's
    TERMS OF USE
    SITE MAP
    Home
    Hosting Plans | Domain Registration | About Us | Contact Us | Site Map
    Terms of Use | Privacy Policy | Guarantees
    Merchant Accounts

    SpiritHost - web hosting for spiritual and education sites
    SpiritHit.com - Religious and Spiritual Portal
  • Return to Table of Contents
  • Back to top

  • Web Hosting: Manuals & FAQ's

    1. Unix-Based Web Hosting
    2. Unix Dedicated Servers
    3. Windows Dedicated Servers
    4. CuteFTP User’s Guide
    5. CuteHTML User’s Guide
    6. WS_FTP Pro User's Guide
    7. Miva Order User's Guide
    8. Miva Merchant User's Guide