Discussion
An attribute A of datatype varchar(20) has the value “Avi” . The attribute B of datatype char(20) has value ”Reed” .Here attribute A has ____ spaces and attribute B has ____ spaces .
Answer: A
Correct answer: 3, 20
The attributes are asked for as stored, not as supplied. A is varchar(20) holding "Avi", and a varying-length type stores only the characters given, so it occupies 3.
B is char(20) holding "Reed". A fixed-length type pads to its full width with trailing spaces, so it occupies 20 whatever the value's length. That padding has a consequence beyond storage: comparisons and concatenations may carry the trailing spaces, which is why char is reserved for values that really are of fixed width.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development