delimiter // #定義標識符為雙斜杠 drop procedure if exists test; #如果存在test存儲過程則刪除 create procedure test() #創建無參存儲過程,名稱為testbegindeclare i int; #申明變量set i = 0; #變量賦值while i < 50 do #結束循環的條件: 當i大于10時跳出while循環INSERT INTO table_test( name)VALUES('123');SET i=i+1; #循環條件不能丟end while; #結束while循環select * from test; #查看test表數據end// #結束定義語句 call test(); #調用存儲過程
以上是mysql循環語句,但我在執行的時候忘了加上SET 循環條件,導致SQL無限循環往表里插入數據
這種情況光是關閉SQL窗口,是不管用的,SQL會在后臺繼續運行,需要找到對應線程,手動殺死
#展示所有運行中的線程,線程信息里會展示對應SQL
SHOW PROCESSLIST;
#殺掉對應線程id KILL 123456;
?