KnowledgeBoat Logo
|

Computer Science

A table Table1 has two text fields defined as below :

:
Name1 varchar(20), 
Name2 char(20),
:

If Name1 stores value as 'Ana' and Name2 stores value as 'Anuj', then Name1 will consume ………….. characters' space and Name2 will consume …………… characters' space.

  1. 3, 20
  2. 20, 4
  3. 20, 20
  4. 3, 4

DDL & DML

1 Like

Answer

3, 20

Reason — For the field Name1 with VARCHAR(20) datatype, storing the value 'Ana' will consume 3 character's space because VARCHAR(n) column can have a maximum size of n bytes and it stores values exactly as specified without adding blanks for shorter lengths. Exceeding n bytes results in an error message. Whereas for the field Name2 with CHAR(20) datatype, storing the value 'Anuj' will consume 20 characters' space because CHAR(n) ensures that all values stored in that column are of length n bytes, padding shorter values with blanks while maintaining a fixed size of n bytes.

Answered By

1 Like


Related Questions