Machine-translated by Google. Questions are authored in English.
Top

Discussion

The basic data type char(n) is a _____ length character string and varchar(n) is _____ length character.

  • A.Fixed, equal
  • B.Equal, variable
  • C.Fixed, variable
  • D.Variable, equal

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.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.