V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
582033
V2EX  ›  MySQL

当 mysql 一字段 update 前后值相同时

  •  
  •   582033 · 2015-11-10 17:40:55 +08:00 · 3540 次点击
    这是一个创建于 3092 天前的主题,其中的信息可能已经有所发展或是发生改变。

    http://ww3.sinaimg.cn/large/7a7443f7jw1exw0n3dqkoj20zu042gmf.jpg

    如图,当 update 前后数值相同时显示为 0 rows affected.
    mysql 在修改前会检测原值么?

    有没有相关的资料?

    3 条回复    2015-11-11 11:50:07 +08:00
    jimmyzhang33
        1
    jimmyzhang33  
       2015-11-10 17:43:27 +08:00
    没有数据发生变化啊,你原来的值就是 1 吧
    mulog
        2
    mulog  
       2015-11-10 18:43:39 +08:00   ❤️ 1
    If you set a column to the value it currently has, MySQL notices this and does not update it.
    http://dev.mysql.com/doc/refman/5.6/en/update.html
    ango
        3
    ango  
       2015-11-11 11:50:07 +08:00
    一般单条数据都冗余一个 updatetime 的数据,每次执行 update 操作都带上 updatetime 的更新,这样可以防止 update 操作前后值相同时程序代码误判 DB 操作失败的情况。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2015 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 16:14 · PVG 00:14 · LAX 09:14 · JFK 12:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.