0
0
MySQLquery~10 mins

BLOB and binary types in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a table with a BLOB column named 'image_data'.

MySQL
CREATE TABLE photos (id INT PRIMARY KEY, image_data [1]);
Drag options to blanks, or click blank then click option'
ABLOB
BTEXT
CVARCHAR(255)
DINT
Attempts:
3 left
💡 Hint
Common Mistakes
Using VARCHAR or TEXT for binary data causes data corruption.
Using INT for storing image data is incorrect.
2fill in blank
medium

Complete the code to insert binary data into the 'image_data' column using a placeholder.

MySQL
INSERT INTO photos (id, image_data) VALUES (1, [1]);
Drag options to blanks, or click blank then click option'
ANULL
BLOAD_FILE('path/to/image.jpg')
CNOW()
D'binarydata'
Attempts:
3 left
💡 Hint
Common Mistakes
Using string literals instead of LOAD_FILE() for binary data.
Using NOW() which returns a datetime, not binary data.
3fill in blank
hard

Fix the error in the query to select the length of binary data stored in 'image_data'.

MySQL
SELECT [1](image_data) FROM photos WHERE id = 1;
Drag options to blanks, or click blank then click option'
ALENGTH
BMAX
CSUM
DCOUNT
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT() which counts rows, not data length.
Using SUM() or MAX() which are aggregate functions not suitable here.
4fill in blank
hard

Fill both blanks to create a table with a fixed-length binary column and insert data into it.

MySQL
CREATE TABLE files (id INT, data [1](16));
INSERT INTO files (id, data) VALUES (1, [2]'abc');
Drag options to blanks, or click blank then click option'
ABINARY
BVARBINARY
CTEXT
DCHAR
Attempts:
3 left
💡 Hint
Common Mistakes
Using TEXT or CHAR for binary data causes errors.
Mixing BINARY and VARBINARY incorrectly.
5fill in blank
hard

Fill all three blanks to select binary data, convert it to hexadecimal, and alias the output.

MySQL
SELECT [1](data) AS [2] FROM files WHERE id = [3];
Drag options to blanks, or click blank then click option'
AHEX
Bbinary_hex
C1
DLENGTH
Attempts:
3 left
💡 Hint
Common Mistakes
Using LENGTH() instead of HEX() for conversion.
Not aliasing the output or using wrong alias.
Using wrong id value in WHERE clause.