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.
- 3, 20
- 20, 4
- 20, 20
- 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
Consider the following SQL statement. What type of statement is this ?
CREATE TABLE employee (name VARCHAR, id INTEGER)
- DML
- DDL
- DCL
- Integrity constraint
The data types
CHAR(n)
andVARCHAR(n)
are used to create ……………, and …………… length types of string/text fields in a database.- Fixed, equal
- Equal, variable
- Fixed, variable
- Variable, equal
Consider the following SQL statement. What type of statement is this ?
INSERT INTO instructor VALUES (10211, 'Shreya' , 'Biology', 66000 ) ;
- Procedure
- DML
- DCL
- DDL
In the given query which keyword has to be inserted ?
INSERT INTO employee ............... (1002, Kausar, 2000) ;
- Table
- Values
- Relation
- Field