Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL部分 #2639

Closed
Xuxiusheng opened this issue Mar 14, 2025 · 1 comment
Closed

MySQL部分 #2639

Xuxiusheng opened this issue Mar 14, 2025 · 1 comment

Comments

@Xuxiusheng
Copy link

在MySQL的NULL与“”对比的那一部分写到“”是不占用空间的,但是

  1. 如果是char字段,需要填充到指定长度,是占用空间的
  2. 如果是varchar字段,其实和NULL一样是有隐藏字段来标识字段实际长度的,这个标识字段为1或2个字节,并且每个变长字段都会有一个
    所以,综上的话,其实“”字符串实际上是占用空间的
@Snailclimb
Copy link
Owner

在MySQL的NULL与“”对比的那一部分写到“”是不占用空间的,但是

  1. 如果是char字段,需要填充到指定长度,是占用空间的
  2. 如果是varchar字段,其实和NULL一样是有隐藏字段来标识字段实际长度的,这个标识字段为1或2个字节,并且每个变长字段都会有一个
    所以,综上的话,其实“”字符串实际上是占用空间的

不好意思,这里我前几个月就已经修改了,但还未同步到网站上去:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants