In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you about the difference between NULL and Empty String in Mysql. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Create table tablist (TABLE_SCHEMA varchar (40), TABLE_NAME varchar (40), COLUMN_NAME varchar (40), COLUMN_TYPE varchar (40), IS_NULLABLE varchar (10), COLUMN_DEFAULT varchar (40), COLUMN_COMMENT varchar (1000), REMARK varchar (2000) Insert into tablist (TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME,COLUMN_TYPE,IS_NULLABLE,COLUMN_DEFAULT,COLUMN_COMMENT) select TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME,COLUMN_TYPE,IS_NULLABLE,COLUMN_DEFAULT,COLUMN_COMMENTfrom information_ schema.`COLUMNS` where TABLE_SCHEMA='leo'
Then query the tablist table:
See which columns do not have comment, so:
Select * from tablist where COLUMN_COMMENT is null
The result turned out to be Empty set. However, from the above query results and navicat, you can see that the null value shows the word 'null'' in the result set, while the empty string is empty.
After looking up the data, it is found that there is a difference between the null value of Mysql and the empty string. It is strange that the null value of COLUMN_COMMENT becomes an empty string after insert (the reason is unknown).
Query using select * from tablist where COLUMN_COMMENT=''; is normal.
NULL columns require additional space in the row to record whether their values are NULL.For MyISAM tables, each NULL column takes one bit extra, rounded up to the nearest byte.
In Mysql's myisam engine, null values take up extra storage space (1bit), while empty strings take up no space at all. At the same time, null values can not be stored in the B-tree index, which will cause serious performance problems when the amount of data is large.
The two query methods are also different: null value queries use is null/is not null queries, while empty string uses = or! = queries.
The above is the difference between NULL and Empty String in Mysql shared by Xiaobian. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.