mysql不同语言的Length()返回不同的大小

前端之家收集整理的这篇文章主要介绍了mysql不同语言的Length()返回不同的大小前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

select 

length('abcdefg') english,length('가나다라마바사') korean

from dual
@H_403_5@

这将返回以下.

english korean
7       21
@H_403_5@

是否有任何函数返回字符数而不是字符字节?

我的意思是我需要的是

english korean
7       7
@H_403_5@
最佳答案
the manual:

Returns the length of the string str,measured in bytes. A multi-byte character counts as multiple bytes. This means that for a string containing five 2-byte characters,LENGTH() returns 10,whereas 07001 returns 5.

CHAR_LENGTH()会做你想要的.

猜你在找的MySQL相关文章