CBSE Class 11 Informatics Practices Question 50 of 87

Structured Query Language (SQL) — Question 11

Back to all questions
11
Question

Question 8

Differentiate between char and varchar data types.

Answer
Char datatypeVarchar datatype
Char datatype specifies a fixed length string.Varchar datatype specifies a variable length string.
Defining a length is not required, but the default is 1.Defining a length is required.
CHAR(n) ensures that all values stored in that column are of length n bytes, padding shorter values with blanks while maintaining a fixed size of n bytes.VARCHAR(n) columns have a maximum size of n bytes, storing values exactly as specified without adding blanks for shorter lengths. Exceeding n bytes results in an error message.