首页 > 数据库技术 > 详细

sql update操作结果

时间:2018-06-16 21:26:19      阅读:179      评论:0      收藏:0      [点我收藏+]

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

sql update操作结果

原文:https://www.cnblogs.com/lanyangsh/p/9191398.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!