(mysql.info.gz) Batch Commands
Info Catalog
(mysql.info.gz) mysql Commands
(mysql.info.gz) mysql
(mysql.info.gz) mysql Tips
8.3.2 Executing SQL Statements from a Text File
-----------------------------------------------
The `mysql' client typically is used interactively, like this:
shell> mysql DB_NAME
However, it's also possible to put your SQL statements in a file and
then tell `mysql' to read its input from that file. To do so, create a
text file `text_file' that contains the statements you wish to execute.
Then invoke `mysql' as shown here:
shell> mysql DB_NAME < TEXT_FILE
You can also start your text file with a `USE DB_NAME' statement. In
this case, it is unnecessary to specify the database name on the command
line:
shell> mysql < text_file
If you are running `mysql', you can execute an SQL script file using
the `source' or `\.' command:
mysql> source FILENAME
mysql> \. FILENAME
Sometimes you may want your script to display progress information to
the user; for this you can insert some lines like
SELECT '<info_to_display>' AS ' ';
which will output <info_to_display>.
For more information about batch mode, see Batch mode.
Info Catalog
(mysql.info.gz) mysql Commands
(mysql.info.gz) mysql
(mysql.info.gz) mysql Tips
automatically generated byinfo2html