0
0
MySQLquery~10 mins

Integer types (TINYINT, INT, BIGINT) in MySQL - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Integer types (TINYINT, INT, BIGINT)
Choose Integer Type
TINYINT?
YesRange: -128 to 127
|No
INT?
YesRange: -2,147,483,648 to 2,147,483,647
|No
BIGINT
Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Store Value
Retrieve Value
Use in Queries
This flow shows how MySQL chooses integer types based on size and stores values within their range.
Execution Sample
MySQL
CREATE TABLE example (
  small_num TINYINT,
  normal_num INT,
  big_num BIGINT
);

INSERT INTO example VALUES (127, 2147483647, 9223372036854775807);
Creates a table with three integer columns of different sizes and inserts the maximum values for each type.
Execution Table
StepActionValue InsertedTypeStored ValueNotes
1Insert 127 into small_num127TINYINT127Within TINYINT range (-128 to 127)
2Insert 2147483647 into normal_num2147483647INT2147483647Within INT range (-2,147,483,648 to 2,147,483,647)
3Insert 9223372036854775807 into big_num9223372036854775807BIGINT9223372036854775807Within BIGINT range (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
4Attempt to insert 128 into small_num128TINYINTError128 exceeds TINYINT max 127, causes overflow error
5Attempt to insert 2147483648 into normal_num2147483648INTError2147483648 exceeds INT max 2147483647, causes overflow error
6Retrieve valuesN/AN/A127, 2147483647, 9223372036854775807Values stored correctly
💡 Execution stops on overflow errors when inserting values outside type ranges.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5Final
small_numNULL127127127Error (overflow)Error (overflow)127 (last valid)
normal_numNULLNULL214748364721474836472147483647Error (overflow)2147483647 (last valid)
big_numNULLNULLNULL9223372036854775807922337203685477580792233720368547758079223372036854775807
Key Moments - 3 Insights
Why does inserting 128 into a TINYINT column cause an error?
Because TINYINT can only store values from -128 to 127. Step 4 in the execution_table shows the overflow error when 128 is inserted.
Can INT store values larger than 2,147,483,647?
No, INT's maximum is 2,147,483,647. Step 5 shows an error when trying to insert 2,147,483,648.
Why use BIGINT instead of INT?
BIGINT stores much larger numbers (up to about 9 quintillion). Step 3 shows storing the maximum BIGINT value successfully.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the stored value in 'small_num' after step 1?
A127
B128
CError
DNULL
💡 Hint
Check the 'Stored Value' column in row for step 1.
At which step does inserting a value cause an overflow error for the INT type?
AStep 2
BStep 4
CStep 5
DStep 3
💡 Hint
Look for 'Error' in the 'Stored Value' column for INT type.
If you insert -129 into a TINYINT column, what would happen?
AValue stored successfully
BOverflow error like in step 4
CValue stored as 127
DValue stored as 0
💡 Hint
TINYINT range is -128 to 127, so values outside cause overflow errors.
Concept Snapshot
Integer Types in MySQL:
- TINYINT: 1 byte, range -128 to 127
- INT: 4 bytes, range -2,147,483,648 to 2,147,483,647
- BIGINT: 8 bytes, range -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Values outside these ranges cause overflow errors.
Choose type based on needed number size.
Full Transcript
This visual execution shows how MySQL stores integer values in TINYINT, INT, and BIGINT columns. It starts by creating a table with these three types. Then it inserts the maximum allowed values for each type successfully. When trying to insert values outside the allowed range, such as 128 into TINYINT or 2147483648 into INT, MySQL raises overflow errors. The variable tracker shows how values change or errors occur step by step. Key moments clarify why values outside ranges cause errors and why BIGINT is used for very large numbers. The quiz tests understanding of stored values and overflow points. The snapshot summarizes the ranges and behavior of these integer types.