Docsity

MYSQL PRACTICE PAPER, Exercises of Computer science

Toggle sidebar
bg1
charge should be greater than or equal to 200 :
Based on above table write the sql commands for the following :(Q2 to 16 - one marks each)
2. To show all information about the patients of cardiology department.
3. To list the names of female patients who are in orthopedic dept
4. To list names of all patients with their date of admission in ascending order
5. To display Patient’s Name, Charges, age for male patients only.
6. To insert a new row in the HOSPITAL table wit the following:
11,”mustafa”,37,”ENT”,(25/02/98},250,”M”
7. To increase the charges of female employees working in ENT department by 25 %.
8. To display the detail of doctors whose name’s second character is ‘a’ and second last character is ‘n’;
9. To add a new column contact number in the hospital table with varchar datatype of size 10.
10. To display the structure of the table .
11. To display unique charges value of hospital table.
12. Select length(concat(name , department)) from hospital where month(dateofadm)=1;
13. Select upper(name) , upper(department) from hospital where age between 45 and 60;
14. Write degree and cardinality of above table.
15. Select charges*length(name) , upper(name) from hospital where length(name)>6;
16. Write degree and cardinality of the query:
Select length(concat(name , department)) from hospital where month(dateofadm)=1;
17. What do you mean by foreign key . Explain with a suitable example.
18. Which SQL command should be used to change the datatype of columns of a table.
—-----------------------------------------------------------------------------------------------------------------------------
WORKSHEET - 2
make slno as primary key and assign NOT NULL Constraint to name , check constraint to charge where
1. Write SQL commands to create the following table ( consider datatype and size of the columns by your own
Write output for the following queries:
OXALISS INTERNATIONAL CBSE SCHOOL, THATCHUR
SUB: COMPUTER SCIENCE (083) CLASS : XII
pf3
pf4

Partial preview of the text

Download MYSQL PRACTICE PAPER and more Exercises Computer science in PDF only on Docsity!

charge should be greater than or equal to 200 : Based on above table write the sql commands for the following :(Q2 to 16 - one marks each)

  1. To show all information about the patients of cardiology department.
  2. To list the names of female patients who are in orthopedic dept
  3. To list names of all patients with their date of admission in ascending order
  4. To display Patient’s Name, Charges, age for male patients only.
  5. To insert a new row in the HOSPITAL table wit the following: 11,”mustafa”,37,”ENT”,(25/02/98},250,”M”
  6. To increase the charges of female employees working in ENT department by 25 %.
  7. To display the detail of doctors whose name’s second character is ‘a’ and second last character is ‘n’;
  8. To add a new column contact number in the hospital table with varchar datatype of size 10.
  9. To display the structure of the table.
  10. To display unique charges value of hospital table.
  11. Select length(concat(name , department)) from hospital where month(dateofadm)=1;
  12. Select upper(name) , upper(department) from hospital where age between 45 and 60;
  13. Write degree and cardinality of above table.
  14. Select charges*length(name) , upper(name) from hospital where length(name)>6;
  15. Write degree and cardinality of the query: Select length(concat(name , department)) from hospital where month(dateofadm)=1;
  16. What do you mean by foreign key. Explain with a suitable example.
  17. Which SQL command should be used to change the datatype of columns of a table. —-----------------------------------------------------------------------------------------------------------------------------

WORKSHEET - 2

make slno as primary key and assign NOT NULL Constraint to name , check constraint to charge where

  1. Write SQL commands to create the following table ( consider datatype and size of the columns by your own Write output for the following queries:

OXALISS INTERNATIONAL CBSE SCHOOL, THATCHUR

SUB: COMPUTER SCIENCE (083) CLASS : XII

columnsize by your own):

  1. Write SQL command to remove all rows of employee table.
  2. Write SQL command to change column name no by empno and set it as primary key.
  3. Write SQL Command to insert at top 3 rows in the above given table.
  4. To show all information about the employees of Engg. Branch.
  5. To list the names of female employees who are in Science branch
  6. To display Employee’s name , Salary ,Age for male employees only in ascending order of their age.
  7. To list the names and department of all employees with their date of retirement in ascending order.
  8. To display Employee’s name , annual Salary ,Age for female employees only where annual salary = salary *12;
  9. To display employee detail whose salary is greater than 2000 but less than 3000.
  10. To display a report of employee details with columns employee name , dateofrtd and department for employees who are retiring in the year 98.
  11. To delete the record of employee who belongs to science department.
  12. To increase the salary of all female employees by 12000 who are about to retire in the month of december.
  13. Write SQL command to Display all the tables available in database ‘DB1’.
  14. Write difference between DDL and DML commands. And also write two commands of each category with their syntax; Write output for below given queries:
  15. Select upper(name) , age from employee where age in(32, 44,25);
  16. Select name , age , salary + salary*12/100 as “increased salary” where department in(‘engg.’,’estbl’) and name like ‘%j’;
  17. Select no , name , age , department from employee where length(name)>6; —------------------------------------------------------------------------------------------------------------
  18. Write SQL command to create the following table Employee(only structure , assume datatype and

Write SQL Commands :

  1. To create a database FUTURE DESIGNER
  2. To activate the above database.
  3. To create the above table with itemname as primary key , price should not be less than 5000 and default discount 10. 2
  4. To increase the discount of double bed furnitures by 20 %.
  5. To delete the sofa furnitures with price below 9000 and discount only 10.
  6. To display no , itemname and price of furnitures for which stock month is february and year is 2002.
  7. To display detail of interiors in descending order of price for which furniture type is either Office table or Dining table.
  8. to list ITEMNAME and TYPE of those items, in which DATEOFSTOCK is be 22/01/02 from the INTERIORS table in descending order of ITEMNAME.
  9. To display unique furniture types of interior table.
  10. To remove the dateof stock column from interior table. Write output for :
  11. Select COUNT(distinct TYPE) from INTERIORS;
  12. Select AVG(DISCOUNT) from INTERIORS where TYPE = “ Baby Cot”;
  13. Select SUM(Price) from INTERIORS where DATOFSTOCK < ‘ 12/02/02’;
  14. Select price*10/100 as “net discount” where type in (‘baby cot ‘,’sofa’);
  15. Select concat(itemname,’is’ , type, ‘ of price ‘,price ,’and’ , discount) from interiors where itemname like ‘R%’ order by price;
  16. Write difference between alter and update commands of mysql with suitable example. —---------------------------------------------------------------------------------------------------------------------------------------------------
  17. What do you mean by a candidate key. Identify at least 4 possible candidate keys of the above table. 4.