start transaction;update participants set cash=cash-12.99 where id=1;
update participants set cash=cash+12.99 where id=2;
update trunks set owner=1 where name='Abacus' and owner=2;select * from participants;
update trunks set owner=1 where name='Abacus' and owner=2;这条语句出错:
You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column为什么会这样??我的记录,字段,类型都没有错的,而且我在my.ini中也#safe-mode了,为什么还是这样子呢?

解决方案 »

  1.   

    SET SQL_SAFE_UPDATES=0;
    再试试使用安全更新模式的时候update语句必须使用一个关键字列属性来限定更新的范围。如果不使用关键字列来限定范围或更新所有记录的时候就不能用安全更新模式。解决办法是执行以下语句设置为非安全更新模式.SET SQL_SAFE_UPDATES=0;
      

  2.   

    show variables like '%sql_safe_update%';看看sql_safe_update的值是什么如果是on 就在执行set sql_safe_updates=off
      

  3.   

    where条件没有索引 本身会锁表很长时间  建议还是加上索引吧
      

  4.   

    我把owner=2(owner创建表时设置了references 另一个表的id(这个是primary key))改成id=1(是同一条记录)就没事了!