(mysql.info) batch-commands
Info Catalog
(mysql.info) mysql-commands
(mysql.info) mysql
(mysql.info) mysql-tips
8.5.3 Executing SQL Statements from a Text File
-----------------------------------------------
The `mysql' client typically is used interactively, like this:
shell> mysql DB_NAME
However, it is 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
If you place a `USE DB_NAME' statement as the first statement in the
file, it is unnecessary to specify the database name on the command
line:
shell> mysql < text_file
If you are already running `mysql', you can execute an SQL script file
using the `source' or `\.' command:
mysql> source FILE_NAME
mysql> \. FILE_NAME
Sometimes you may want your script to display progress information to
the user. For this you can insert statements like this:
SELECT '<info_to_display>' AS ' ';
The statement shown outputs `<info_to_display>'.
For more information about batch mode, see batch-mode.
Info Catalog
(mysql.info) mysql-commands
(mysql.info) mysql
(mysql.info) mysql-tips
automatically generated byinfo2html