Junior
From PDF
SQL
SQL & Databases
What is the difference between CHAR and VARCHAR data types in SQL?
Short answer: CHAR: A fixed-length string data type. It always reserves the same amount of space regardless of the string's length. Use case: When the length of the string is known and consistent. VARCHAR: A variable-length string data type. It only uses as much space as needed to store the string. Use case: When the string length can vary.
Example code
CREATE TABLE Example ( fixed_char CHAR(10), variable_char VARCHAR(10) );
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png