Challenge - 5 Problems
Integer Types Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Output of TINYINT overflow in MySQL
Consider a MySQL table with a column defined as
TINYINT (signed). What will be the output of the following query?SELECT CAST(130 AS SIGNED TINYINT) AS result;MySQL
SELECT CAST(130 AS SIGNED TINYINT) AS result;
Attempts:
2 left
💡 Hint
Remember that TINYINT signed range is from -128 to 127, and values outside wrap around.
✗ Incorrect
TINYINT signed can store values from -128 to 127. Casting 130 overflows and wraps around, resulting in -126.
🧠 Conceptual
intermediate1:30remaining
Range of BIGINT unsigned in MySQL
What is the maximum value that can be stored in a
BIGINT UNSIGNED column in MySQL?Attempts:
2 left
💡 Hint
BIGINT is 8 bytes, unsigned means all bits used for positive values.
✗ Incorrect
BIGINT unsigned uses 64 bits for positive values only, so max is 2^64 - 1 = 18446744073709551615.
📝 Syntax
advanced1:30remaining
Correct syntax for defining an INT column with display width
Which of the following is the correct syntax to define an
INT column with a display width of 5 in MySQL?Attempts:
2 left
💡 Hint
MySQL allows specifying display width in parentheses after the type name.
✗ Incorrect
The correct syntax is INT(5). Other options are invalid keywords.
❓ optimization
advanced2:00remaining
Choosing integer types for storage optimization
You need to store user ages ranging from 0 to 120 in a MySQL table. Which integer type is the most storage-efficient choice without risking overflow?
Attempts:
2 left
💡 Hint
Consider the range and storage size of each integer type.
✗ Incorrect
TINYINT unsigned stores 0 to 255 using 1 byte, enough for ages 0-120, saving space.
🔧 Debug
expert2:30remaining
Why does this BIGINT assignment cause an error?
Given the table
users with a column id BIGINT SIGNED, why does this insert fail?INSERT INTO users (id) VALUES (9223372036854775808);Attempts:
2 left
💡 Hint
Check the maximum value allowed for BIGINT SIGNED.
✗ Incorrect
BIGINT SIGNED max is 9223372036854775807. The inserted value is one more, causing out-of-range error.