Maharishi International Residential School 083 Computer Science - Worksheet On SQL Commands
Maharishi International Residential School 083 Computer Science - Worksheet On SQL Commands
Maharishi International Residential School 083 Computer Science - Worksheet On SQL Commands
QUESTIONS
1 Which command of SQL is used to change/modify the structure of a table?
2 Ms. Shruti has created a table GAMES having attributes ID, GAME, NO_OF_PLAYERS. Later she
wants to add a new attribute DURATION of integer type in this table. How can she do this?
Write down a full command.
3 A table TEACHER has attributes CODE, NAME, POST, CATEGORY. Write down command to
delete the attribute CATEGORY from this table.
4 A table TEACHER has no primary key. Which command will be used to make one if its
attribute named CODE its primary key?
5 What will happen if following command is executed : -
ALTER TABLE EMPLOYEE DROP PRIMARY KEY;
6 Differentiate ALTER TABLE and UPDATE command?
7 While working in MySql Mr. Hitesh wants to delete an existing table MEMBER, but he is
confused between DELETE and DROP TABLE commands. Help him to choose the correct one
out of the following commands: -
DROP TABLE MEMBER;
DELETE FROM MEMBER;
8 What is the purpose of IS NULL and IS NOT NULL operators?
9 What is the use of LIKE operator in SQL?
10
11 What do you mean by the term alias in SQL? Explain briefly by an example? 2
12 Write the name of any two commands under DDL and DML each ? 2
13
1. To display the details of the Employee whose price is in the range of 5000 to 10000(Both values
included).
2. To increase the salary of Employee by 20% as a bonus.
3. To list the names of those employees who belong to city jaipur,delhi,sikar.
4. To display unique city from a table Employee.
5. Add a new record in above table with the following data:(8,rehan,delhi,3-4-2006,4000)
6. To arrange records in descending order of name.
7. List the names of employees whose salary is more than 200000 and less than 300000.
8. In above table Ram has forgotten to define primary key.Now he wants to define
primary key in the above table.Help ram to write command to make Emp_ID as primary key.
9. Mr. Ram wants to remove the above table with its structure.Help ram to write
command to remove above table.
10. Mr.Harish has left the company.Kindly remove his record from the above table.
In the above table Emp_ID is the primary key.Now Mr ram wants to remove this
constraint. Help ram to write commands for the same.
11. Display the name of an employee whose salary is not defined yet.
12. Mr.Ram wants to give salary rs 5000 to those employees whose salary is not defined
yet.Ram has written the following query:
13. Update Employee Set Salary=5000 having Salary is not NULL
14. Display the names of employee whose city name is of 4-character long.
Q.19 Consider the given table Player and answer the questions given below:
1. To display the details of Players who scored centuries in ascending order of their name .
2. To increase the salary of Player by 50% if he scored a century.
3. To list the names of those Players whose name length is 5 characters and end with 'ESH' .
4. To display unique city from table Player.
5. add a new record in above table with the following data: (8,piyush,kota,90,14000)
6. List the names of Players who belong to city jaipur or tonk.
7. Mr. Ram wants to add one more column "coach_name" .Help ram to write commands .
8. To Display records in descending order of Salary.
Q. 20 What is the Cartesian product of two tables? 2
Q. 21 What is the difference between where clause and having clause? 1
Q. 22 What is equi join? Explain with suitable example. 2
Q. 23 Answer the following questions based on table CUSTOMER and ORDER.
(i) Which column can be most suitable to set as a primary key in table customer with suitable
explanation?
(ii) Ram wants to set CUSTOMER_ID as a foreign key in table ORDER. But he is facing some
problem. Help Ram to remove discrepancy if any that restrict CUSTOMER_ID to act as a foreign
key. Note:(Primary Key in table CUSTOMER:ID, Primary Key in table ORDER:ORDER_ID)