当前位置:网站首页>MySQL "invalid use of null value" solution
MySQL "invalid use of null value" solution
2022-07-07 13:51:00 【Full stack programmer webmaster】
1. Problem description
Because to change ”information” In the table ” Number ” Column is not empty , Use database query statements “alter table information modify ‘ Number ’ varchar(255) not null” You can change other columns , But it's just an error in the number column , The error message is Invalid use of NULL value.
Is very strange , Other columns can be queried by using this command , Why can't you check only the number column .
2. The reason for the error
The reason for this error may be the existing data ‘ Number ’ As a null, And not null The settings of conflict .( The reason found ).
I think it's because when I first created a new data table , The table structure of this column has been set , When making subsequent changes, it will conflict with the previous settings ( As for why it can't be changed here , I don't quite understand ), Because I set the structure attribute of the numbered column when creating a new table .
Since it cannot be set to non empty , So create a new column and set not null, You can succeed .
3. terms of settlement
1) Add new column , Set the structure properties of the column .
alter table information add column ‘yyy’ varchar(255) not null first; - Add a new column yyy To the first column .
2) Copy the contents of the wrong column into the new column and delete the wrong column
update information set yyy=’ Number ’; — take ’ Number ’ All values of the column are copied to yyy Column .
alter table information drop ‘ Number ’; — Delete the wrong column .
3) Modify the new column name to the wrong column name
alter table information change ‘yyy’ ‘ Number ’ varchar(255) not null;
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113291.html Link to the original text :https://javaforall.cn
边栏推荐
- 2022-7-7 Leetcode 34.在排序数组中查找元素的第一个和最后一个位置
- JS slow motion animation principle teaching (super detail)
- Centso7 OpenSSL error Verify return code: 20 (unable to get local issuer certificate)
- 2022-7-6 使用SIGURG来接受外带数据,不知道为什么打印不出来
- Advanced Mathematics - Chapter 8 differential calculus of multivariate functions 1
- [dark horse morning post] Huawei refutes rumors about "military master" Chen Chunhua; Hengchi 5 has a pre-sale price of 179000 yuan; Jay Chou's new album MV has played more than 100 million in 3 hours
- mysql导入文件出现Data truncated for column ‘xxx’ at row 1的原因
- The reason why data truncated for column 'xxx' at row 1 appears in the MySQL import file
- 作战图鉴:12大场景详述容器安全建设要求
- Toraw and markraw
猜你喜欢
Use of polarscatter function in MATLAB
供应链供需预估-[时间序列]
Redis can only cache? Too out!
2022-7-6 使用SIGURG来接受外带数据,不知道为什么打印不出来
Distributed transaction solution
High end for 8 years, how is Yadi now?
C语言数组相关问题深度理解
Dry goods | summarize the linkage use of those vulnerability tools
How far can it go to adopt a cow by selling the concept to the market?
SSRF漏洞file伪协议之[网鼎杯 2018]Fakebook1
随机推荐
Redis只能做缓存?太out了!
xshell连接服务器把密钥登陆改为密码登陆
Ikvm of toolbox Net project new progress
Supply chain supply and demand estimation - [time series]
Toraw and markraw
ROS机器人更换新雷达需要重新配置哪些参数
Solve the cache breakdown problem
PostgreSQL array type, each splice
AI人才培育新思路,这场直播有你关心的
ES日志报错赏析-Limit of total fields
JS slow motion animation principle teaching (super detail)
"New red flag Cup" desktop application creativity competition 2022
toRaw和markRaw
Deep understanding of array related problems in C language
Flask session forged hctf admin
Move base parameter analysis and experience summary
Esp32 construction engineering add components
My "troublesome" subordinates after 00: not bad for money, against leaders, and resist overtime
供应链供需预估-[时间序列]
Redis 核心数据结构 & Redis 6 新特性详