当前位置:网站首页>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
边栏推荐
- Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)
- 最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
- 作战图鉴:12大场景详述容器安全建设要求
- 【日常训练】648. 单词替换
- Talk about pseudo sharing
- Introduction and basic use of stored procedures
- MySQL error 28 and solution
- [daily training] 648 Word replacement
- Navicat run SQL file import data incomplete or import failed
- Build a secure and trusted computing platform based on Kunpeng's native security
猜你喜欢
566. 重塑矩阵
C语言数组相关问题深度理解
How to make join run faster?
Redis只能做缓存?太out了!
如何让join跑得更快?
10 pictures open the door of CPU cache consistency
Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
Flink | 多流转换
Digital IC Design SPI
Supply chain supply and demand estimation - [time series]
随机推荐
xshell连接服务器把密钥登陆改为密码登陆
Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)
Shell batch file name (excluding extension) lowercase to uppercase
648. Word replacement: the classic application of dictionary tree
参数关键字Final,Flags,Internal,映射关键字Internal
实现IP地址归属地显示功能、号码归属地查询
postgresql array类型,每一项拼接
2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
What are the principles for distinguishing the security objectives and implementation methods that cloud computing security expansion requires to focus on?
Battle Atlas: 12 scenarios detailing the requirements for container safety construction
Introduction and basic use of stored procedures
[high frequency interview questions] difficulty 2.5/5, simple combination of DFS trie template level application questions
Help tenants
move base参数解析及经验总结
Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)
My "troublesome" subordinates after 00: not bad for money, against leaders, and resist overtime
Custom thread pool rejection policy
供应链供需预估-[时间序列]
Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
Write it down once Net a new energy system thread surge analysis