DELIMITER $$
DROP PROCEDURE IF EXISTS `TESTDB`.`pr_process_list`$$
CREATE DEFINER=`root`@`%` PROCEDURE `TESTDB`.`pr_process_list`()
BEGIN
insert into TESTDB.processcount(num, create_date)
select COUNT(*) ,now()
from information_schema.PROCESSLIST;
insert into TESTDB.processlist(ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, create_date)
select ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO,now()
from information_schema.PROCESSLIST;
END $$
DELIMITER ;
呼叫MySQL StoreProcedure
mysql> CALL `TESTDB`.`pr_process_list`
沒有留言:
張貼留言