The MySQL software also allows you to
run queries without entering the mysql client itself. To do so is to use mysql in what is called batch mode.
Instead of entering queries directly, you can store them in a text file and
then run the text file through mysql.
Command:
mysql -u username
-p databasename < '/path/to/filename.txt'
example:
mysql –u root sampledb
<c:\query.txt
If you want to save the result of a batch file as its own text file,
add > '/path/to/output.txt to
your code. The line bin/mysql -u username
-p < '/path/to/input.txt' > '/path/to/output.txt'
example:
mysql –u root rhams <c:\query.txt > d:\output.txt
Batch files can also be run from
within the mysql
client, if you'd prefer. Just log in, select your database, and then type:
source/path/to/filename
No comments:
Post a Comment