mysql中使用innodb引擎即可, 详见文档:
If you use FOR UPDATE on a storage engine that uses page or row locks, rows examined by the query are write-locked until the end of the current transaction. Using LOCK IN SHARE MODE sets a shared lock that prevents other transactions from updating or deleting the examined rows

解决方案 »

  1.   

    或者你可能需要用lock tables语法,如果使用MyISAM引擎的话。
      

  2.   

    mysql> select * from a for update;
    +------+
    | a    |
    +------+
    |   10 |
    |   20 |
    |   30 |
    |   10 |
    |   10 |
    +------+
    5 rows in set (0.00 sec)版本是Server version: 5.6.14 MySQL Community Server (GPL)。 innodb engine.
      

  3.   

    mysql怎么不行了
    毕竟一个开源,一个收费
      

  4.   

    mysql暂时版本是没有此功能的。
      

  5.   

    为何都认为mysql没有此功能?
    select **** for update, 要结合transaction来使用的。
    假定使用的是InnoDB引擎,默认是读已提交隔离级,
    会话1: 
    mysql> begin;
    Query OK, 0 rows affected (0.00 sec)mysql> select * from t for update;
    +----+------+
    | id | col2 |
    +----+------+
    |  1 | wa   |
    |  2 | ch   |
    +----+------+
    2 rows in set (0.00 sec)mysql>
    会话2:
    mysql> begin;
    Query OK, 0 rows affected (0.00 sec)mysql> update t set col2='ww' where id=1;update操作会hang在那里,与需求相符。直到出现:ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
    这时如果会话1,执行commit操作, 会话2的update操作立即完成。
      

  6.   

    楼主的ORALCE中的FOR UPDATE是指什么? MYSQL本身是有 select * from xx for update
      

  7.   

    select from ue_order where id = 1 for update;
      

  8.   


    例如我用navicat,我改一条数据。
    1)
    select * from table where id=222 这个可以直接在显示的行中修改数据。2)
    select t.realname,t.address from table t where t.id =222
    这个是修改不了的,如果是oracle +for update 是可以修改数据的。
      

  9.   


    例如我用navicat,我改一条数据。
    1)
    select * from table where id=222 这个可以直接在显示的行中修改数据。2)
    select t.realname,t.address from table t where t.id =222
    这个是修改不了的,如果是oracle +for update 是可以修改数据的。
    请看我在7楼的回帖,前边要加begin的。
    否则for update会失去作用。这是与oracle的区别。
      

  10.   


    例如我用navicat,我改一条数据。
    1)
    select * from table where id=222 这个可以直接在显示的行中修改数据。2)
    select t.realname,t.address from table t where t.id =222
    这个是修改不了的,如果是oracle +for update 是可以修改数据的。
    请看我在7楼的回帖,前边要加begin的。
    否则for update会失去作用。这是与oracle的区别。select *  不用加for update也能修改。select t.realname,t.address from table t where t.id =222这种是不行的。
      

  11.   

    这不是MYSQL本身的问题了。是navicat的问题了。对MYSQL来说,最终都只是执行SQL语句而已。 建议先在MYSQL本身的命令行工具下测试。 而非MYSQL官方提供的工具,MYSQL本身并不提供保证。
      

  12.   

    你的修改,应该是工具带来的便利, 而和select * ...for update没关系.
    我经常用的EMS for mysql,select的数据也可以修改。