Reading this question a doubt poped into my head:
读到这个问题,我的脑海中突然出现了一个疑问:
- char and varchar can store up to 255 chars
- char和varchar可以存储最多255个字符。
- text can store up to 65k chars
- 文本可以存储到65k字符。
- char size in bytes is number of chars
- 字符大小(以字节为单位)是字符数
- varchar size in bytes is number of chars used + 1
- varchar大小(字节)是使用的字符数+ 1
So how much bytes does TEXT actually occupies? ~65kb or number of chars used + 1?
那么文本占用了多少字节呢?~65kb或使用的字号+ 1?
2 个解决方案
#1
27
TEXT is a variable length datatype, with a maximum of 65,000 characters.
文本是一个可变长度的数据类型,最多有65,000个字符。
LONGTEXT can be used for over 4 trillion characters.
长文本可用于超过4万亿字符。
To answer your question: it's a variable lenght, and it will only occupy the amount of characters you store.
回答您的问题:它是一个可变的lenght,它只占用您存储的字符数量。
#2
7
TEXT occupies a number actual length of your data + 2 bytes.
文本占用数据的实际长度+ 2字节。
#1
27
TEXT is a variable length datatype, with a maximum of 65,000 characters.
文本是一个可变长度的数据类型,最多有65,000个字符。
LONGTEXT can be used for over 4 trillion characters.
长文本可用于超过4万亿字符。
To answer your question: it's a variable lenght, and it will only occupy the amount of characters you store.
回答您的问题:它是一个可变的lenght,它只占用您存储的字符数量。
#2
7
TEXT occupies a number actual length of your data + 2 bytes.
文本占用数据的实际长度+ 2字节。