In linux, usrbinmysql-uquot; usernamequot;-pquot; passwordquot; dbname -- executequot; deletefromtable1; select *
In linux,/usr/bin/mysql-uquot; usernamequot;-pquot; passwordquot; dbname -- execute = quot; delete from table1; select *
Requirement: at the end of some activities, you need to query game data at a certain time point in time.
Implementation: Two Methods
One worker uses mysql.exe + at/to schedule tasks
D: \ mysql \ bin \ mysql.exe-u "username"-p "password" dbname -- execute = "delete from table1; select * from table2"> c: \ result.txt
Open the specified data warehouse, execute the begin SQL statement, and redirect the result to the result.txt file of the C drive. You can then use the at command and scheduled task for scheduled execution. Of course, you can add the ftp command to upload the query result file to the specified machine.
Linux
/Usr/bin/mysql-u "username"-p "password" dbname -- execute = "delete from table1; select * from table2">/tmp/result
Feature: You need to enable the scheduled task.
Ii. Use the mysql events Function
Enable this function first
Set global event_scheduler = 1;
The following statement runs the defined SQL statement at a specified time. For more detailed usage, see the mysql help documentation.
Create event test on schedule at timestamp '2017-09-09 09:00:00 'do select * from db1.table1 into outfile 'result.txt ';
Features: the mysql version must be 5.1.6 or later, and may affect the performance to a certain extent.