Challenge - 5 Problems
BLOB Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this BLOB insertion query?
Consider a MySQL table
What is stored in the
files with a data column of type BLOB. What will be the result of this query?INSERT INTO files (data) VALUES (0x48656C6C6F);What is stored in the
data column?MySQL
CREATE TABLE files (id INT AUTO_INCREMENT PRIMARY KEY, data BLOB); INSERT INTO files (data) VALUES (0x48656C6C6F); SELECT HEX(data) FROM files WHERE id = 1;
Attempts:
2 left
💡 Hint
Remember that 0x48656C6C6F is a hexadecimal literal representing bytes.
✗ Incorrect
The query inserts the bytes represented by the hex literal 0x48656C6C6F into the BLOB column. Selecting HEX(data) returns the hexadecimal string representation of those bytes, which is "48656C6C6F".
🧠 Conceptual
intermediate1:30remaining
Which MySQL data type is best for storing fixed-length binary data?
You want to store a fixed-length binary string of exactly 16 bytes in MySQL. Which data type should you choose?
Attempts:
2 left
💡 Hint
Fixed-length binary means the storage size is always the same.
✗ Incorrect
BINARY(16) stores fixed-length binary data of 16 bytes. VARBINARY is variable length, BLOB is for large binary objects, and TEXT is for character data.
📝 Syntax
advanced2:00remaining
Which query correctly creates a table with a MEDIUMBLOB column?
You want to create a MySQL table named
images with a column img_data that can store up to 16 MB of binary data. Which query is correct?Attempts:
2 left
💡 Hint
MEDIUMBLOB is a valid MySQL data type for medium-sized binary data.
✗ Incorrect
Option D uses the correct syntax and data type MEDIUMBLOB. Option D is invalid because BLOB does not take size parameters. Option D uses BINARY with a very large size which is not allowed. Option D uses LONGBLOB with a size parameter which is invalid.
❓ optimization
advanced2:30remaining
How to optimize queries on a table with large BLOB columns?
You have a MySQL table with a large BLOB column storing images. You often query metadata columns but rarely need the BLOB data. What is the best way to optimize query performance?
Attempts:
2 left
💡 Hint
Fetching large BLOB data unnecessarily slows queries.
✗ Incorrect
Splitting the table separates large binary data from frequently queried metadata, reducing data read and improving performance. Indexing BLOB columns is not supported and converting to TEXT is inappropriate for binary data.
🔧 Debug
expert2:00remaining
Why does this query fail when inserting binary data?
Given the table:
Why does this query fail?
CREATE TABLE docs (id INT PRIMARY KEY, content BLOB);Why does this query fail?
INSERT INTO docs (id, content) VALUES (1, '0x4D7953514C');Attempts:
2 left
💡 Hint
Hexadecimal literals should not be quoted in MySQL.
✗ Incorrect
In MySQL, 0x4D7953514C without quotes is a binary literal. Quoting it makes it a string literal, which does not convert automatically to binary, causing the insert to fail or store wrong data.