Is incrementing a field in MySQL atomic?

前端 未结 6 815
醉梦人生
醉梦人生 2020-12-01 03:40

I\'m making a web site where I would like to increment a counter in a standard MyISAM table.

Simplified example:

UPDATE votes SET num = num + 1;
         


        
6条回答
  •  心在旅途
    2020-12-01 04:20

    Yes, the table (or rows in InnoDB format databases) is automatically locked when you execute an update query.

提交回复
热议问题