The basic data type char(n) is a _____ length character string and varchar(n) is _____ length character.
Answer: C
Correct answer: Fixed, variable
char(n) always occupies \( n \) characters: a shorter value is padded with trailing spaces to fill the width. varchar(n) stores only the characters actually supplied, up to a maximum of \( n \).
The trade is space against predictability. char wastes space on short values but has a fixed offset, which can make row access marginally faster; varchar stores just what is needed at the cost of a length prefix. The practical rule is char for genuinely fixed-width codes and varchar for anything that varies.
Please log in or register to report this question.