Computer Science
Compare Char and Varchar datatypes.
SQL Queries
1 Like
Answer
Char datatype | Varchar 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. |
Answered By
3 Likes