nerdexam
Oracle

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…

Advanced SQL

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)
  • A
    4% (2)
  • B
    2% (1)
  • C
    84% (46)
  • D
    2% (1)
  • E
    9% (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

#String comparison#Collation settings#Case sensitivity#String functions

Community Discussion

No community discussion yet for this question.

Full 1Z0-909 Practice