› 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
quietin
V2EX  ›  MySQL

关于插入纪录时进 set id=0 无效的问题

  •  
  •   quietin · Jan 11, 2016 · 3249 views
    This topic created in 3920 days ago, the information mentioned may be changed or developed.

    +------------+--------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +------------+--------------+------+-----+---------+----------------+
    | id | int(11) | NO | PRI | NULL | auto_increment |
    | desc | varchar(100) | NO | | NULL | |
    +------------+--------------+------+-----+---------+----------------+

    对于这样的表,如果插入 id 为 0 的纪录,会插入成功,但插入的纪录 id 不为 0 而是自增后的值,但是 id 为-1 时,则能成功插入并且 id=-1 ,这是为什么?

    insert into content_cornermark set id=-1, content_cornermark.desc='无';

    3 replies  •  2016-01-12 15:14:37 +08:00
    geeglo
        1
    geeglo  
       Jan 11, 2016
    -1 在 int 的范围中
    msg7086
        2
    msg7086  
       Jan 12, 2016   ❤️ 1
    Let me google that for you:
    http://stackoverflow.com/a/1142588
    quietin
        3
    quietin  
    OP
       Jan 12, 2016
    @geeglo 0 难道不是 int 么
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1022 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 17:30 · PVG 01:30 · LAX 10:30 · JFK 13:30
    ♥ Do have faith in what you're doing.