1Z0-909 · Question #32
Examine these statements: SET collation_connection=utf8mb4_0900_as_cs; SELECT STRCMPCAlice', UCASE ('Alice* )) ; What is displayed?
The correct answer is C. -1. UCASE('Alice') produces 'ALICE', so the call becomes STRCMP('Alice', 'ALICE'). Because the session collation is utf8mb4_0900_as_cs (cs = case-sensitive), these two strings are not equal. Under UCA (Unicode Collation Algorithm), lowercase letters carry a lower tertiary weight…
Question
Examine these statements:
SET collation_connection=utf8mb4_0900_as_cs; SELECT STRCMPCAlice', UCASE ('Alice* )) ; What is displayed?
Options
- A0
- BERROR: 1267 (HYOOO): Illegal mix of collations
- C-1
- DNULL
- E1
How the community answered
(55 responses)- A4% (2)
- B2% (1)
- C84% (46)
- D2% (1)
- E9% (5)
Explanation
UCASE('Alice') produces 'ALICE', so the call becomes STRCMP('Alice', 'ALICE'). Because the session collation is utf8mb4_0900_as_cs (cs = case-sensitive), these two strings are not equal. Under UCA (Unicode Collation Algorithm), lowercase letters carry a lower tertiary weight than their uppercase counterparts, so 'Alice' sorts before 'ALICE'; STRCMP returns -1 when the first argument is less than the second.
Why each distractor is wrong:
- A (0) - STRCMP returns 0 only for equal strings; a case-sensitive collation prevents that here.
- B (ERROR 1267) - that error fires on an illegal mix of different, incompatible collations in a single expression; here only one collation is in play.
- D (NULL) - STRCMP yields NULL only when at least one argument is NULL; neither argument is NULL.
- E (1) - that would require
'Alice'to sort after'ALICE', but UCA places lowercase before uppercase.
Memory tip: Anchor the suffix _cs to "Case Sensitive," then remember the UCA rule: lower case = lower weight = less than uppercase, so a mixed-case string always compares as less than its fully uppercased twin, giving −1.
Topics
Community Discussion
No community discussion yet for this question.