Recall & Review
beginner
What is the main difference between VARCHAR and CHAR in MySQL?
VARCHAR stores variable-length strings and uses only as much space as needed plus 1 or 2 bytes for length. CHAR stores fixed-length strings and always uses the full length, padding with spaces if needed.
Click to reveal answer
beginner
When should you use TEXT instead of VARCHAR or CHAR?
Use TEXT when you need to store large amounts of text data up to 65,535 bytes (larger than the maximum effective length of VARCHAR). TEXT types are designed for longer text storage with off-row storage.
Click to reveal answer
intermediate
How does MySQL store trailing spaces in CHAR and VARCHAR columns?
CHAR pads shorter strings with spaces to fill the fixed length, and the padding spaces are removed on retrieval. VARCHAR stores the exact string without padding, preserving trailing spaces.
Click to reveal answer
intermediate
What is the maximum length of a VARCHAR column in MySQL?
The maximum length of a VARCHAR column is 65,535 bytes, but this depends on the character set and row size limits.
Click to reveal answer
advanced
Explain the storage difference between TEXT and VARCHAR in MySQL.
TEXT columns are stored outside the table row with a pointer in the row, while VARCHAR stores data directly in the row. TEXT is better for large text but can be slower to access.
Click to reveal answer
Which string type in MySQL uses fixed-length storage?
✗ Incorrect
CHAR uses fixed-length storage, always reserving the full length specified.
What happens if you store a shorter string in a CHAR(10) column?
✗ Incorrect
CHAR pads shorter strings with spaces to fill the fixed length.
Which type is best for storing very long text data?
✗ Incorrect
TEXT is designed for large text data up to 65,535 bytes.
How does VARCHAR store its data in MySQL?
✗ Incorrect
VARCHAR stores variable-length strings with a length prefix to know the size.
What is a limitation of TEXT compared to VARCHAR?
✗ Incorrect
TEXT columns have limitations on indexing; only a prefix can be indexed.
Describe the differences between VARCHAR, CHAR, and TEXT in MySQL.
Think about storage size, padding, and typical use cases.
You got /4 concepts.
Explain how MySQL handles trailing spaces in CHAR and VARCHAR columns.
Consider how fixed vs variable length affects space storage.
You got /3 concepts.