0
0
MySQLquery~20 mins

BLOB and binary types in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
BLOB Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output of this BLOB insertion query?
Consider a MySQL table 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;
A"48656C6C6F"
B"0x48656C6C6F"
C"Hello"
D"68656C6C6F"
Attempts:
2 left
💡 Hint
Remember that 0x48656C6C6F is a hexadecimal literal representing bytes.
🧠 Conceptual
intermediate
1: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?
ATEXT
BVARBINARY(16)
CBINARY(16)
DBLOB
Attempts:
2 left
💡 Hint
Fixed-length binary means the storage size is always the same.
📝 Syntax
advanced
2: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?
ACREATE TABLE images (id INT PRIMARY KEY, img_data BLOB(16MB));
BCREATE TABLE images (id INT PRIMARY KEY, img_data BINARY(16777216));
CCREATE TABLE images (id INT PRIMARY KEY, img_data LONGBLOB(16));
DCREATE TABLE images (id INT PRIMARY KEY, img_data MEDIUMBLOB);
Attempts:
2 left
💡 Hint
MEDIUMBLOB is a valid MySQL data type for medium-sized binary data.
optimization
advanced
2: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?
AUse SELECT * to always fetch all columns including BLOB.
BSplit the table into two: one with metadata and one with BLOB data, joining only when needed.
CConvert BLOB columns to TEXT to improve query speed.
DCreate an index on the BLOB column to speed up queries.
Attempts:
2 left
💡 Hint
Fetching large BLOB data unnecessarily slows queries.
🔧 Debug
expert
2:00remaining
Why does this query fail when inserting binary data?
Given the table:
CREATE TABLE docs (id INT PRIMARY KEY, content BLOB);
Why does this query fail?
INSERT INTO docs (id, content) VALUES (1, '0x4D7953514C');
ABecause '0x4D7953514C' is treated as a string, not binary data.
BBecause BLOB columns cannot store hexadecimal values.
CBecause the id column is missing AUTO_INCREMENT.
DBecause the quotes around 0x4D7953514C are required for binary literals.
Attempts:
2 left
💡 Hint
Hexadecimal literals should not be quoted in MySQL.