AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
#### 行锁 innodb存储引擎(**myisam不支持行锁**)是通过给索引上的索引项加锁来实现的,这就意味着:**只有通过索引条件检索数据**,innodb才会使用行级锁,否则,innodb使用表锁。 **也就是说,想要innodb支持行锁, 表中必须添加主键.** 语法: ~~~ begin; 执行语句; commit; ~~~ 进程1: ~~~ mysql> begin; //加锁 Query OK, 0 rows affected (0.00 sec) mysql> update user set name = 'zhenjie' where id = 2; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> commit; //释放锁 Query OK, 0 rows affected (0.00 sec) ~~~ 进程2: ~~~ mysql> update user set name = 'jie' where id = 2; Query OK, 1 row affected (4.67 sec) //对于同一条数据等待了进程1释放写锁,才能进行修改. Rows matched: 1 Changed: 1 Warnings: 0 ~~~