mysql - sql在数据库中插入错误的值

标签 mysql

这是我的请求,

INSERT INTO user(name,user_id,url,email,created,updated,phone,organisationID,role) VALUES ('Bastien Frey', '2196898165', 'https://cubber.zendesk.com/api/v2/users/2196898165.json', 'bastien.frey@incityz.com', '2016-01-19T16:21:07Z', '2016-01-19T16:21:07Z', '', '30567951','end-user'),('mathilde zimmer', '2297486669', 'https://cubber.zendesk.com/api/v2/users/2297486669.json', 'mathilde.zimmer91290@gmail.com', '2016-01-26T12:04:20Z', '2016-01-26T12:04:20Z', '', '36094152','end-user')

但是它在我的表中插入了错误的user_id,您认为这是代码问题还是数据库问题? 在我的数据库中我有类似的东西: enter image description here

最佳答案

您已将 user_id 列定义为有符号整数,并且您尝试插入大于 upper limit of this data type 的值(2147483647)。 MySQL 将值截断为数据类型允许的最大值(您没有启用严格的 sql 模式,否则您将收到错误)。使用 show warnings 命令查看警告。

将字段的数据类型更改为 unsigned int 或(无符号)bigint。

关于mysql - sql在数据库中插入错误的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38094984/

相关文章:

sql - 优化 SQL 距离查询

MySQL 比较行并获取更改

mysql:从连接返回多个 csv 列

mysql - 涉及聚合函数的 SQL 查询

mysql - Spring + MyBatis - 设置数据源

mysql - mySQL 中的重复记录

MYSQL JOIN SELECT 语句 - 省略重复项

php - 从 url 中获取值并将其传递给 codeigniter 中的另一个页面

php - AngularJS 和 Laravel 4.2 从多个表中检索数据并连接它们

mysql:select * where first and last name starts with the same letter