MySQL 更新一个不同的数字

标签 mysql database

update profiles_profiles set unconfirmed_phone=2222222222 where id = 1;


mysql> select * from profiles_profiles\G
*************************** 1. row ***************************
               id: 1
          user_id: 1
            phone: NULL
unconfirmed_phone: 2147483647

出于某种原因,我的更新不适用于“2222222222”。但是,它适用于 1111111111。

MySQL 始终会更新所有其他字段,但每次都会将 unconfirmed_phone 更改为 2147483647。

mysql> desc profiles_profiles;
+-------------------+----------+------+-----+---------+----------------+
| Field             | Type     | Null | Key | Default | Extra          |
+-------------------+----------+------+-----+---------+----------------+
| id                | int(11)  | NO   | PRI | NULL    | auto_increment |
| user_id           | int(11)  | NO   | UNI | NULL    |                |
| phone             | int(11)  | YES  | UNI | NULL    |                |
| unconfirmed_phone | int(11)  | YES  |     | NULL    |                |


*************************** 8. row ***************************
           Name: products_products
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 0
 Avg_row_length: 0
    Data_length: 16384
Max_data_length: 0
   Index_length: 16384
      Data_free: 5242880
 Auto_increment: 1
    Create_time: 2013-04-11 05:23:31
    Update_time: NULL
     Check_time: NULL
      Collation: utf8_general_ci
       Checksum: NULL
 Create_options: 
        Comment: 

最佳答案

它只是意味着你要更新当前值的新值只是溢出了。 signed int 的最大允许值为 2147483647

有时电话号码的数据类型可以简单地为 varchar,因为其他人用 (, ), - 等符号保存它

手册摘录,

The maximum value depends on the system. 32 bit systems have a maximum signed integer range of -2147483648 to 2147483647. So for example on such a system, intval('1000000000000') will return 2147483647. The maximum signed integer value for 64 bit systems is 9223372036854775807.

关于MySQL 更新一个不同的数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15941482/

相关文章:

mongodb - 建议何时/如何将数据保存到数据库,插入到 MongoDB 时

mysql - 将数据导入MySQL数据库

MYSQL - 'a' 中的未知列 'field list'

mysql - SQL Now() 仅解析日期

php - 查询发生时如何到 "close"数据库?

database - 如何从数据库中获取现场时间

php - 使用 mysql_fetch_array 将记录彼此相邻地放入列中?

mysql - Zenoss核心安装与MySQL的兼容性问题

python - MYSQL LOAD DATA INFILE 忽略具有非唯一值列的重复行

database - 由于类型转换未使用索引?