V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
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 · Nov 10, 2015 · 4243 views
    This topic created in 3825 days ago, the information mentioned may be changed or developed.

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

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

    有没有相关的资料?

    3 replies    2015-11-11 11:50:07 +08:00
    jimmyzhang33
        1
    jimmyzhang33  
       Nov 10, 2015
    没有数据发生变化啊,你原来的值就是 1 吧
    mulog
        2
    mulog  
       Nov 10, 2015   ❤️ 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  
       Nov 11, 2015
    一般单条数据都冗余一个 updatetime 的数据,每次执行 update 操作都带上 updatetime 的更新,这样可以防止 update 操作前后值相同时程序代码误判 DB 操作失败的情况。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2770 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 14:05 · PVG 22:05 · LAX 07:05 · JFK 10:05
    ♥ Do have faith in what you're doing.