Computer Science
In a table in MYSQL database, an attribute A of datatype varchar(20) has the value "Keshav". The attribute B of datatype char(20) has value “Meenakshi”. How many characters are occupied by attribute A and attribute B ?
- 20, 6
- 6, 20
- 9, 6
- 6, 9
Answer
6, 20
Reason — The datatype VARCHAR(20) is a variable-length character string that can store up to 20 characters. When "Keshav" (6 characters) is assigned to attribute A with VARCHAR(20), it occupies only 6 characters of storage space because VARCHAR adjusts the space based on the actual data length. The datatype CHAR(20) is a fixed-length character string that always occupies the specified amount of space, in this case, 20 characters. When "Meenakshi" (9 characters) is assigned to attribute B with CHAR(20), it still occupies all 20 characters of storage space because CHAR pads the data with spaces to fill up the allocated space, even if the actual data is shorter.
Related Questions
State True or False:
"In a Python program, if a break statement is given in a nested loop, it terminates the execution of all loops in one go."
What will be the output of the following statement:
print(3 - 2 2 3 + 99/11)
- 244
- 244.0
- -244.0
- Error
Select the correct output of the code:
s = "Python is fun" l = s.split() s_new = "-".join([l[0].upper(), l[1], l[2].capitalize()]) print(s_new)
- PYTHON-IS-Fun
- PYTHON-is-Fun
- Python-is-fun
- PYTHON-Is -Fun
In MYSQL database, if a table, Alpha has degree 5 and cardinality 3, and another table, Beta has degree 3 and cardinality 5, what will be the degree and cardinality of the Cartesian product of Alpha and Beta?
- 5, 3
- 8, 15
- 3, 5
- 15, 8