0
0
MySQLquery~5 mins

String types (VARCHAR, CHAR, TEXT) in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ACHAR
BTEXT
CVARCHAR
DBLOB
What happens if you store a shorter string in a CHAR(10) column?
AIt pads the string with spaces to length 10
BIt stores the string as TEXT
CIt truncates the string to 5 characters
DIt stores only the characters without padding
Which type is best for storing very long text data?
AVARCHAR
BCHAR
CTEXT
DINT
How does VARCHAR store its data in MySQL?
AFixed length with padding
BOutside the row with pointer
CAs binary data
DVariable length with length prefix
What is a limitation of TEXT compared to VARCHAR?
ATEXT cannot store NULL values
BTEXT cannot be indexed fully
CTEXT has a smaller maximum size
DTEXT stores data inline always
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.