在第 1 行 im mysql 的列“profile_pic"的数据被截断 [英] Data truncated for column 'profile_pic' at row 1 im mysql
问题描述
错误 1265:第 1 行profile_pic"列的数据被截断
ERROR 1265: Data truncated for column 'profile_pic' at row 1
SQL 语句:
ALTER TABLE `student`.`student_info`
CHANGE COLUMN `profile_pic` `profile_pic` VARCHAR(50) NOT NULL DEFAULT 'images/profile.png'
错误:运行故障回复脚本时出错.详情如下.
ERROR: Error when running failback script. Details follow.
错误 1050:表 'student_info' 已经存在
ERROR 1050: Table 'student_info' already exists
SQL 语句:
CREATE TABLE `student_info` (
`name` varchar(45) NOT NULL,
`email` varchar(45) NOT NULL,
`password` varchar(45) NOT NULL,
`profile_pic` varchar(500) DEFAULT 'images/profile.png',
PRIMARY KEY (`email`),
UNIQUE KEY `email_UNIQUE` (`email`),
UNIQUE KEY `password_UNIQUE` (`password`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
当我将 profile_pic 列的值设置为非空时,此错误正在闪烁,但是如果我不这样做,则不会发生此错误,任何机构都可以向我解释为什么会发生此错误以及如何删除此错误
this error is flashing when i am setting the value of profile_pic column as not null however if i am not not doing so this error is not occurring can any body please explain me why is this error occurring and how to remove this
推荐答案
将您的 Alter 查询更改为
Change your Alter query to
ALTER TABLE `student`.`student_info`
CHANGE COLUMN `profile_pic` `profile_pic` VARCHAR(500) NOT NULL DEFAULT 'images/profile.png'
在您的架构中,您之前已使用 varchar(500)
定义了 profile_pic
现在您尝试将其设置为不为 null 而是使用 varchar(50)
所以你的列包含的数据长度超过 50 个字符,因此你会看到这个被截断的错误
In your schema you have previously defined profile_pic
with varchar(500)
now you are trying to set it not null but with varchar(50)
so your column contains the data which is longer than 50 characters therefore you see this truncated error
这篇关于在第 1 行 im mysql 的列“profile_pic"的数据被截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!