Advertisements
Advertisements
Question
In a table in the MYSQL database, an attribute A of datatype varchar(20) has the value “Keshav”. The attribute B of datatype char(20) has the value “Meenakshi”. How many characters are occupied by attribute A and attribute B?
Options
20,6
6,20
9,6
6,9
Solution
6,20
Explanation:
Keshav has a 6-character length. Varchar is known to have a changeable length. Therefore, even if the field's width is 20, it will only use the characters' total length. Rather, char has a set length. Regardless of the number of characters in the actual data, it will take up the entire number of characters set aside for the field.
APPEARS IN
RELATED QUESTIONS
Which of the following is not a valid SQL type?
MySQL is not:
In database, a column is known as:
What does data type indicate?
______ decides the operations that can be performed on an attribute.
Which datatype specifies character type data of length where n could be any value from 0 to 65535?
Date datatype is stored as:
Restrictions on the type of values that an attribute can have are referred to as:
Using the sports database containing two relations (TEAM, MATCH_DETAILS) and write the Query for the following:
Change the name of the relation TEAM to T_DATA. Also, change the attributes TeamID and TeamName to T_ID and T_NAME respectively.
Differentiate between CHAR and VARCHAR data types in SQL with appropriate examples.
Kabir wants to write a program in Python to insert the following record in the table named Student in MYSQL database,
SCHOOL:
- rno(Roll number) - integer
- name(Name) - string
- DOB (Date of birth) - Date
- Fee - float
Note the following to establish connectivity between Python and MySQL:
- Username - root
- Password - tiger
- Host - localhost
The values of fields rno, name, DOB and fee has to be accepted from the user. Help Kabir to write the program in Python.
Zack is working in a database named SPORT, in which he has created a table named “Sports” containing columns SportId, SportName, no_of_players, and category.
After creating the table, he realized that the attribute, category has to be deleted from the table and a new attribute TypeSport of data type string has to be added. This attribute TypeSport cannot be left blank. Help Zack write the commands to complete both the tasks.
Sartaj has created a table named Student in MYSQL database, SCHOOL:
- rno(Roll number )- integer
- name(Name) - string
- DOB (Date of birth) – Date
- Fee – float
Note the following to establish connectivity between Python and MySQL:
- Username - root
- Password - tiger
- Host - localhost
Sartaj, now wants to display the records of students whose fee is more than 5000. Help Sartaj to write the program in Python.