Which statement(s) from following list are true for BINARY and VARBINARY data types?

Which statement(s) from following list are true for BINARY and VARBINARY data types?

Which statement(s) from following list are true for BINARY and VARBINARY data types?

A.
When BINARY values are stored, they are right-padded with null values to the specified length

B.
When VARBINARY values are stored, they are right-padded with null values to the specified length

C.
When BINARY values are retrieved, trailing nulls are removed

D.
When VARBINARY values are retrieved, trailing nulls are removed



Leave a Reply 1

Your email address will not be published. Required fields are marked *


Shahriyar Rzayev

Shahriyar Rzayev

The correct answers are A and C…It says that:
A.When BINARY values are stored, they are right-padded with null values to the specified length…

Why with null values?

In MySQL 5.5 Documentation mentioned about this:
When BINARY values are stored, they are right-padded with the pad value to the specified length. The pad value is 0x00 (the zero byte).

And there is another issue about this test…
C.When BINARY values are retrieved, trailing nulls are removed

But again from MySQL 5.5 Documentation:
Values are right-padded with 0x00 on insert, and no trailing bytes are removed on select.

From Documentation:
” When BINARY values are stored, they are right-padded with the pad value to the specified length. The pad value is 0x00 (the zero byte). Values are right-padded with 0x00 on insert, and no trailing bytes are removed on select. All bytes are significant in comparisons, including ORDER BY and DISTINCT operations. 0x00 bytes and spaces are different in comparisons, with 0x00 < space.

Example: For a BINARY(3) column, 'a ' becomes 'a ' when inserted. 'a' becomes 'a' when inserted. Both inserted values remain unchanged when selected. "

Please explain this test…