An attribute A of data type varchar(20) has the value ‘xyz’ and attribute B of data type char(20) has the value “Imnop” , then the attribute A has ________ spaces and attribute B has ________ spaces.

This question was previously asked in
UGC NET Computer Science (Paper 2) Dec 2018 Paper
View all UGC NET Papers >
  1. 20, 20
  2. 3, 20
  3. 3, 5
  4. 20, 5

Answer (Detailed Solution Below)

Option 2 : 3, 20
Free
UGC NET Paper 1: Held on 21st August 2024 Shift 1
13 K Users
50 Questions 100 Marks 60 Mins

Detailed Solution

Download Solution PDF
Concept:
Char and varchar types are similar but differ in their storing and retrieval way. They also have different maximum length.
Explanation:
Char: When char is declared with a length than its length is fixed with that is declared during the creation of the table. Some points about char:
  • It has fixed length,
  • It loads empty spaces.
  • Length ranges from 0 to 255
  • When char values are stored, they are right padded with spaces to the specified length.
     
Here, char(20) is given for value “lmnop”. Length is fixed in char. So, attribute B has 20 spaces.
Varchar: Values in varchar columns are of variable length. Some points about varchar are as follows:
 
  • Length can be specified from 0 to 65535.
  • The effective maximum length is subject to maximum row size
  • Varchar values are stored as 1 byte or 2 byte length prefix plus data.
  • It doesn’t use the entire declared length.
     
Here, varchar(20) has the value “xyz” for attribute A. So, attribute A takes 3 spaces.
Latest UGC NET Updates

Last updated on Jun 19, 2025

-> The UGC NET City Slip 2025 has been released on its official website today.

-> The UGC NET June 2025 exam will be conducted from 25th to 29th June 2025.

-> The UGC-NET exam takes place for 85 subjects, to determine the eligibility for 'Junior Research Fellowship’ and ‘Assistant Professor’ posts, as well as for PhD. admissions.

-> The exam is conducted bi-annually - in June and December cycles.

-> The exam comprises two papers - Paper I and Paper II. Paper I consists of 50 questions and Paper II consists of 100 questions. 

-> The candidates who are preparing for the exam can check the UGC NET Previous Year Papers and UGC NET Test Series to boost their preparations.

More ER Model Questions

Get Free Access Now
Hot Links: teen patti 50 bonus teen patti 51 bonus real teen patti