MySQL進階技術-交易處理及鎖,mysql交易處理

來源:互聯網
上載者:User

MySQL進階技術-交易處理及鎖,mysql交易處理
MySQL進階技術-交易處理及鎖
mysql怎用事務與鎖 鎖住某一行資料,使得不允許兩個使用者同時讀取一行資料

這個是不能實現的,mysql就算鎖住單行資料,但是其他線程還是會有讀鎖的,我覺得你要實現這樣的功能,你可以給這個表再加上個欄位,用於表示是否被某個線程讀取,被讀取的時候可以把這個標誌位改成1,然後其他線程在select的時候根據這個標識位為0的,這樣就無法讀取到了
 
mysql鎖表什時可以用到 怎鎖表 有例子參考的

鎖表和解鎖語句:

LOCK TABLES 表名 write|read;
UNLOCK TABLES;
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.