sql update操作结果

Mysql

在MySQL中只有真正对记录进行修改了的情况下,row_count才会去记录影响的行数,否则如果记录存在但是没有实际修改则不会将该次更新记录到row_count中。

update操作执行结果为更新成功的行数。
如果其值为0,有两种情况:

  • 记录不存在
    此时不会更新任何记录
  • 记录存在,要更新的字段的值与字段的当前值相同
    此时不会更新任何记录
    例如,
    update tbl_orange set value=1 where id=1;
    如果id为1的记录,字段value的值已经为1,那么update操作结果为0。

另外,与Mysql版本也有关系,5.5,5.6中真正对记录进行修改才会记录影响的行数。

For UPDATE statements, the affected-rows value by default is the number of rows actually changed. If you specify the CLIENT_FOUND_ROWS flag to mysql_real_connect() when connecting to mysqld, the affected-rows value is the number of rows “found”; that is, matched by the WHERE clause.

ORACLE

在ORACLE,只要更新的记录存在,则不论实际有没有修改数据,影响的行数都会被累积记录下来。

参考

https://blog.csdn.net/win7system/article/details/73658270

http://blog.51cto.com/samyubw/223776

https://my.oschina.net/zimingforever/blog/83810

https://dev.mysql.com/doc/refman/5.5/en//information-functions.html#function_row-count

猜你喜欢

转载自www.cnblogs.com/lanyangsh/p/9191398.html
今日推荐