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

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details