0
0
MySQLquery~20 mins

Integer types (TINYINT, INT, BIGINT) in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Integer Types Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2: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;
A127
B-126
C130
D0
Attempts:
2 left
💡 Hint
Remember that TINYINT signed range is from -128 to 127, and values outside wrap around.
🧠 Conceptual
intermediate
1:30remaining
Range of BIGINT unsigned in MySQL
What is the maximum value that can be stored in a BIGINT UNSIGNED column in MySQL?
A18446744073709551615
B9223372036854775807
C4294967295
D2147483647
Attempts:
2 left
💡 Hint
BIGINT is 8 bytes, unsigned means all bits used for positive values.
📝 Syntax
advanced
1: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?
ACREATE TABLE t (col INT(5));
BCREATE TABLE t (col INT WIDTH 5);
CCREATE TABLE t (col INT DISPLAY 5);
DCREATE TABLE t (col INT SIZE 5);
Attempts:
2 left
💡 Hint
MySQL allows specifying display width in parentheses after the type name.
optimization
advanced
2: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?
ASMALLINT SIGNED
BBIGINT UNSIGNED
CTINYINT UNSIGNED
DINT SIGNED
Attempts:
2 left
💡 Hint
Consider the range and storage size of each integer type.
🔧 Debug
expert
2: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);
AThe value is too small for BIGINT SIGNED causing underflow
BSyntax error due to missing quotes around the number
CBIGINT SIGNED cannot store positive numbers
DValue exceeds BIGINT SIGNED max limit causing out-of-range error
Attempts:
2 left
💡 Hint
Check the maximum value allowed for BIGINT SIGNED.