CBSE Class 12 Computer Science Question 53 of 91

Relational Database and SQL — Question 14

Back to all questions
14
Question

Question 11

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.