1Z0-873 · Question #129
You are using a multi-byte character set with variable-length encoding. You need to store records whose values are always 20 characters. Which of the following column types would be the most…
The correct answer is B. VARCHAR. For multi-byte character sets that have variable-length encoding, a variable-length data type may be appropriate even if stored values always have the same number of characters. The utf8 character set uses one to three bytes per characters. For fixed-length data types, three…
Question
You are using a multi-byte character set with variable-length encoding. You need to store records whose values are always 20 characters. Which of the following column types would be the most efficient to use in terms of storage space?
Options
- ACHAR
- BVARCHAR
- CThe storage requirements for CHAR or VARCHAR would be the same
How the community answered
(30 responses)- A13% (4)
- B80% (24)
- C7% (2)
Explanation
For multi-byte character sets that have variable-length encoding, a variable-length data type may be appropriate even if stored values always have the same number of characters. The utf8 character set uses one to three bytes per characters. For fixed-length data types, three bytes per character must always be allocated to allow for the possibility that every character will require the "widest" encoding. Thus, CHAR (32) requires 96 bytes, even if most stored values contain 32 single-byte characters. For variable-length data types, only as much storage is allocated as required. In a VARCHAR(32) column, a 32-character string that consists entirely of three-byte characters requires 96 bytes plus a length byte, whereas it requires only 32 bytes plus a length byte if the string consists entirely of single-byte characters.
Topics
Community Discussion
No community discussion yet for this question.