CBSE Class 12 Computer Science Question 28 of 78

Simple Queries in SQL — Question 4

Back to all questions
4
Question

Question 4

Compare Char and Varchar datatypes.

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.