Complete the code to create a table with a BLOB column named 'image_data'.
CREATE TABLE photos (id INT PRIMARY KEY, image_data [1]);The BLOB type is used to store binary large objects such as images.
Complete the code to insert binary data into the 'image_data' column using a placeholder.
INSERT INTO photos (id, image_data) VALUES (1, [1]);
The LOAD_FILE() function reads a file and returns its contents as binary data for insertion.
Fix the error in the query to select the length of binary data stored in 'image_data'.
SELECT [1](image_data) FROM photos WHERE id = 1;
The LENGTH() function returns the number of bytes in the binary data.
Fill both blanks to create a table with a fixed-length binary column and insert data into it.
CREATE TABLE files (id INT, data [1](16)); INSERT INTO files (id, data) VALUES (1, [2]'abc');
BINARY(16) creates a fixed-length binary column. BINARY is used to insert binary data.
Fill all three blanks to select binary data, convert it to hexadecimal, and alias the output.
SELECT [1](data) AS [2] FROM files WHERE id = [3];
HEX() converts binary data to hexadecimal string. The alias binary_hex names the output column. The WHERE clause filters by id = 1.