Hax0r

[MySQL] length() vs char_length() 본문

0x00 개발/Database

[MySQL] length() vs char_length()

영준이 2016.04.08 14:54

LENGTH function returns the length of the string measured in bytes.

CHAR_LENGTH() returns the length of the string measured in characters.


1. LENGTH() : 길이를 bytes로 나타낸다.
SELECT LENGTH('한글') -> 6
SELECT LENGTH('abc') -> 3

2. CHAR_LENGTH() : 글자의 수를 나타낸다.
SELECT CHAR_LENGTH('한글') -> 2
SELECT CHAR_LENGTH('abc') -> 3

3. BIT_LENGTH() : 길이를 bit로 나타낸다.
SELECT BIT_LENGTH('한글a') -> 56
SELECT BIT_LENGTH('한글')   -> 48


0 Comments
댓글쓰기 폼