update student s, city c
set s.city_name = c.name
where s.city_code = c.code;
這個寫法會造成city鎖死,有哪些方案可以避免,降低MySQL的資料隔離級別是最好嗎?
uj5u.com熱心網友回復:
不懂你的業務邏輯,如果student.code是number型別,那么可以試一下這個。DECLARE
begin
FOR i IN 0..99 LOOP
update student s, city c
set s.city_name = c.name
where s.city_code = c.code and mod(s.city_code,100);
END LOOP;
end ;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/49905.html
標籤:MySQL
上一篇:一個簡單的SQL查詢問題
下一篇:mysql 鏈表查詢不呼叫索引?
