环境:
mysql> show variables like '%storage_engine%';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
1 row in set (0.00 sec)
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.1.52 |
+-----------+
1 row in set (0.06 sec)
SQL> select * from v$version where rownum=1;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
SQL> !uname -a
Linux Think 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
对mysql而言,select for update必须在一个事务中,当事务commit,锁也就释放了。因此,在实验时,务必加个begin、start transaction 或者 set autocommit=0。
&n

本文对比了MySQL和Oracle数据库在使用`select ... for update`语句时的锁行为。通过实验环境展示了不同数据库在事务处理和行级锁定上的区别,为数据库开发者和管理员提供参考。
最低0.47元/天 解锁文章

374

被折叠的 条评论
为什么被折叠?



