Advertisements
Advertisements
Question
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.
Solution
To delete the attribute, category:
ALTER TABLE Sports
DROP category;
To add the attribute, TypeSport
ALTER TABLE Sports
ADD TypeSport char(10) NOT NULL;
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:
Differentiate between CHAR and VARCHAR data types in SQL with appropriate examples.
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?
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.
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.