Test Index

Structured Query Language (SQL) Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 39 of 58
Marks: +1, -0
Mr. Ravi is creating a field that contains alphanumeric values and fixed lengths. Which MySQL data type should he choose for the same ?
[CBSE 2024 Compartment]
Solution:  
Concept:
CHAR(n) stores a fixed-length string of n characters (shorter values are padded with spaces). VARCHAR(n) stores a variable-length string of up to n characters.
Explanation:
The field holds alphanumeric values (letters and digits, so a string type) of a fixed length, for example a code like AB1234. The best choice is CHAR.
VARCHAR is for variable lengths; LONG and NUMBER are not MySQL string types.
Answer:
Option B (CHAR)
© examsnet.com
Advertisements
Go to Question: