1. Direct Input SQL execution
Mysql> Select Now ();
+---------------------+
| Now () |
+---------------------+
| 2013-09-18 13:55:45 |
+---------------------+
1 row in Set (0.00 sec)
2. Execute the prepared SQL script
Mysql> Source H:/1.sql
+---------------------+
| Now () |
+---------------------+
| 2013-09-18 13:54:04 |
+---------------------+
1 row in Set (0.00 sec)
3.select. into outfile Execute SQL
Mysql> Select Now () into outfile ' h:/data/2.sql ';
Query OK, 1 row Affected (0.00 sec)
4. Use the MySQL command to execute
H:\>mysql-uahmin-p-E "Select Now"
Enter PASSWORH: * * *
+---------------------+
| Now () |
+---------------------+
| 2013-09-18 13:57:09 |
+---------------------+
The 5.mysql command executes SQL and saves the results of the query to text
A) Execute simple SQL
Mysql-uahmin-proot test-e "Select Now ()" N >h:/work/target1.txt
If the SQL is very long, this approach is not very appropriate.
b) executing complex SQL
Complex SQL can be edited in advance and stored in text for execution.
h:\> mysql-uroot-pmypwh-h127.0.0.1-p3306 Test < h:/work/source.sql > H:/work/target.txt
The last execution mode plus the operating system timing tasks, you can implement the scheduled execution of SQL in MySQL, and save the purpose of execution results.
Reference: 3.5 of the official documents. Using MySQL in Batch Mode
Http://dev.mysql.com/doc/refman/5.6/en/batch-mode.html
The above is a small series for everyone to bring the MySQL command line in the execution of SQL several ways to summarize all the content, I hope that we support cloud-Habitat Community ~