일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- Sring Functions and Operators
- Date and Time Functions
- 티베로
- Date and Time Function
- Data and Time Functions
- String Function and Operators
- 전자정부 표준프레임워크
- Tibero
- 방화벽
- String Functions and Date Operators
- 오라클
- 전자정부표준프레임워크
- HTTP
- SVN
- String Functions and Operators
- 윈도우
- MySQL
- Oracle
- Today
- Total
웹이야기
[MySQL]WEIGHT_STRING() 본문
MySQL 문자열 함수와 연산자
WEIGHT_STRING()
-
WEIGHT_STRING(str [AS {CHAR | BINARY} (N)] [flags])
의 형태
This function returns the weight string for the input string. The return value is a binary string that represents the comparison and sorting value of the string. It has these properties :
- If WEIGHT_STRING(str1) = WEIGHT_STRING(str2), then str1 = str2(str1 and str2 are considered equal)
- If WEIGHT_STRING(str1) < WEIGHT_STRING(str2), then str1 < str2(str1 sorts before str2)
WEIGHT_STRING() is a debugging function intended for internal use. Its behavior can change without notice between MySQL versions. It can be used for testing and debugging of collations, espcially if you are adding a new collation.
(MySQL 8. xx 기준)
This list briefly summarizes the arguments. More details are given in the discussion following the list.
- str : The input string expression.
- As clause : Optinal; cast the input string to a given type and length.
- flags : Optional; unused.
The input string, str, is a string expression. If the input is a nonbinary (character) string such as a CHAR, VARCHAR, or TEXT value, the return value contains the collation weights for the string. If the input is a binary(byte) string such as a BINARY, VARBINARY, or BLOB value, the return value is the same as the input(the weight for each byte in a binary string is the byte value). If the input is NULL, WEIGHT_STRING() returns NULL.
mysql> SET @s = _utf8mb4 'AB' COLLATE utf8mb4_0900_ai_ci ;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @s, HEX(@s), HEX(WEIGHT_STRING(@s)) ;
+------+---------+------------------------+
| @s | HEX(@s) | HEX(WEIGHT_STRING(@s)) |
+------+---------+------------------------+
| AB | 4142 | 1C471C60 |
+------+---------+------------------------+
1 row in set (0.01 sec)
mysql> SET @s = _utf8mb4 'ab' COLLATE utf8mb4_0900_ai_ci ;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @s, HEX(@s), HEX(WEIGHT_STRING(@s)) ;
+------+---------+------------------------+
| @s | HEX(@s) | HEX(WEIGHT_STRING(@s)) |
+------+---------+------------------------+
| ab | 6162 | 1C471C60 |
+------+---------+------------------------+
1 row in set (0.00 sec)
mysql> SET @s = CAST('AB' AS BINARY );
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @s, HEX(@s), HEX(WEIGHT_STRING(@s));
+------+---------+------------------------+
| @s | HEX(@s) | HEX(WEIGHT_STRING(@s)) |
+------+---------+------------------------+
| AB | 4142 | 4142 |
+------+---------+------------------------+
1 row in set (0.00 sec)
mysql> SET @s = CAST('ab' AS BINARY) ;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @s, HEX(@s), HEX(WEIGHT_STRING(@s));
+------+---------+------------------------+
| @s | HEX(@s) | HEX(WEIGHT_STRING(@s)) |
+------+---------+------------------------+
| ab | 6162 | 6162 |
+------+---------+------------------------+
1 row in set (0.00 sec)
mysql>
'D > MySQL' 카테고리의 다른 글
[MySQL] 칼럼 추가 / 삭제 (0) | 2021.01.22 |
---|---|
[MySQL]UPPER() (0) | 2020.06.18 |
[MySQL]UNHEX() (0) | 2020.06.18 |
[MySQL]UCASE() (0) | 2020.06.18 |
[MySQL]TRIM() (0) | 2020.06.18 |