当前位置:网站首页>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
边栏推荐
- toRaw和markRaw
- Custom thread pool rejection policy
- postgresql array类型,每一项拼接
- 2022-7-6 Leetcode 977.有序数组的平方
- Solve the cache breakdown problem
- 【日常训练--腾讯精选50】231. 2 的幂
- 2022-7-7 Leetcode 844.比较含退格的字符串
- DID登陆-MetaMask
- . Net core about redis pipeline and transactions
- Indoor ROS robot navigation commissioning record (experience in selecting expansion radius)
猜你喜欢
提升树莓派性能的方法
Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)
LED light of single chip microcomputer learning notes
Esp32 construction engineering add components
Navicat运行sql文件导入数据不全或导入失败
xshell连接服务器把密钥登陆改为密码登陆
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)
How far can it go to adopt a cow by selling the concept to the market?
JS slow motion animation principle teaching (super detail)
随机推荐
[daily training -- Tencent select 50] 231 Power of 2
Read PG in data warehouse in one article_ stat
Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
My "troublesome" subordinates after 00: not bad for money, against leaders, and resist overtime
Huawei image address
2022-7-7 Leetcode 34. Find the first and last positions of elements in a sorted array
JS function returns multiple values
Dry goods | summarize the linkage use of those vulnerability tools
Environment configuration of lavarel env
2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
Ikvm of toolbox Net project new progress
[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
Getting started with MySQL
2022-7-6 beginner redis (I) download, install and run redis under Linux
云计算安全扩展要求关注的安全目标和实现方式区分原则有哪些?
2022-7-6 Leetcode 977. Square of ordered array
2022-7-6 Leetcode27.移除元素——太久没有做题了,为双指针如此狼狈的一天
Supply chain supply and demand estimation - [time series]
Ways to improve the performance of raspberry pie