当前位置:网站首页>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
边栏推荐
- Mysql怎样控制replace替换的次数?
- 最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
- Build a secure and trusted computing platform based on Kunpeng's native security
- PostgreSQL array type, each splice
- Drawerlayout suppress sideslip display
- Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)
- PHP - laravel cache
- Split screen bug notes
- Flink | 多流转换
- 2022-7-6 Leetcode 977.有序数组的平方
猜你喜欢
2022-7-6 Leetcode 977. Square of ordered array
LED light of single chip microcomputer learning notes
Dry goods | summarize the linkage use of those vulnerability tools
提升树莓派性能的方法
2022-7-6 Leetcode 977.有序数组的平方
Navicat运行sql文件导入数据不全或导入失败
Redis can only cache? Too out!
Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou
TPG x AIDU | AI leading talent recruitment plan in progress!
《厌女:日本的女性嫌恶》摘录
随机推荐
566. Reshaping the matrix
Clion mingw64 Chinese garbled code
Split screen bug notes
call undefined function openssl_ cipher_ iv_ length
Write it down once Net a new energy system thread surge analysis
ES日志报错赏析-Limit of total fields
如何让join跑得更快?
干货|总结那些漏洞工具的联动使用
MySQL error 28 and solution
高等数学---第八章多元函数微分学1
云计算安全扩展要求关注的安全目标和实现方式区分原则有哪些?
Introduction to database system - Chapter 1 introduction [conceptual model, hierarchical model and three-level mode (external mode, mode, internal mode)]
10 pictures open the door of CPU cache consistency
Mysql怎样控制replace替换的次数?
接口自动化测试-接口间数据依赖问题解决
Esp32 ① compilation environment
1、深拷贝 2、call apply bind 3、for of for in 区别
THINKPHP框架的优秀开源系统推荐
作战图鉴:12大场景详述容器安全建设要求
Detr introduction