0% found this document useful (0 votes)
17 views3 pages

Practical List Term 2 Class 12 CS

Uploaded by

potatotify0550
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

Practical List Term 2 Class 12 CS

Uploaded by

potatotify0550
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Mr.

SURYA PRATAP SINGH

CLASS 12(CS) PRACTICALS LIST FROM MySQL


Q.1- Create a database 'School' on the database server, show the list of databases and open it.
Q2.- Create the following table named 'STUDENT' with appropriate data type, size and constraint(s)
if any.
Field Name Data Type Size Constraints
ROLL INTEGER 12 PRIMARY KEY
NAME CHAR 20
DOB DATE
CITY VARCHAR 20
MARKS FLOAT 10
Q3.- Insert the following details in the table:
ROLL NAME DOB GENDER CITY MARKS
101 RYAN SHARMA 2002-12-11 M MEERUT 450.87
102 SHIKSHA 2001-11-01 F DELHI 670.95
103 MOHITA 2002-08-05 F MUMBAI 890.45
104 RYAN VERMA 2000-04-21 M MEERUT 540.63
105 ISHAN 1999-12-21 M LUCKNOW 688.36
106 MITALI 1999-11-09 F DELHI 999.78
107 ADHARSH 2000-10-10 M MUMBAI 887.55
Q4. Display all the information of males whose city is NEITHER Delhi nor Mumbai.
Q5. Display the details of all students whose date of birth lies before year 2002 and after year 1999.
Q6. Display all the information in alphabetically decreasing order of their names.
Q7. Display all columns arranged in descending order of city and within the city in the ascending
order their marks.
Q8. List names of all students whose name has the character ‘a’.
Q9. Display Name and Marks of those students whose marks is in the range 400 and 800 ( both are
inclusive)
Q10.Display city-name and total number of students from that city .
Q11.Display city-name and sum of marks of the students from each city.
Q12.Display average marks, highest marks and total no. of students for each city.
Q13.Display total no of males and females separately, along with their average marks.
Q14. Increase the marks by 5% of the students who belongs to meerut.
Q15. Add one more column to the table with the name “contact number” (data type – varchar and
size 12).
Q16 . Remove existing primary key from the table.
Q17. Add primary key constraint to the column “NAME”.
Q18. Display roll,name and marks of those students who belongs to meerut or delhi or lucknow.
Q19. Consider the tables PRODUCT and BRAND given below:
Table: PRODUCT
Mr. SURYA PRATAP SINGH
Table: BRAND

I. Display product name and brand name from the tables PRODUCT and BRAND.
II. Display the average rating of Medimix and Dove brands
III. Display the name, price, and rating of products in descending order of rating.

Q20 .Write the outputs of the SQL queries (i) to (iv) based on the relations Teacher and Placement
given below:

I. SELECT Department, avg(salary) FROM Teacher GROUP BY Department;


II. SELECT MAX(Date_of_Join),MIN(Date_of_Join) FROM Teacher;
III. SELECT Name, Salary, T.Department, Place FROM Teacher T, Placement P WHERE T.Department =
P.Department AND Salary>20000;
IV. SELECT Name, Place FROM Teacher T, Placement P WHERE Gender =’F’ AND
T.Department=P.Department;

Q21. Consider two tables, Orders (OrderID, CustomerID, OrderAmount) and Customers
(CustomerID, CustomerName). Write a query to show each CustomerName and their total
OrderAmount, but only include customers whose total OrderAmount is above $2,000.
Q22. Given two tables, Sales (SalesPersonID, ProductID, SaleAmount) and Products (ProductID,
Category, Price), write a query to find each Category and the total SaleAmount generated, but only
include categories with total sales over $10,000.
Mr. SURYA PRATAP SINGH

Q23 Write queries (a) to (d) based on the tables EMPLOYEE and DEPARTMENT given below:

a) To display the average salary of all employees, department wise.


b) To display name and respective department name of each employee whose salary is more
than 50000.
c) To display the names of employees whose salary is not known, in alphabetical order.
d) To display DEPTID from the table EMPLOYEE without repetition.
Q24. Write a program to create a connection between python IDLE and mySQL. Print message as
“successfully connected ” when connected.
Q25. Write a program to open the database and access the data of STUDENT table using the python
–mysql connectivity.
Q26. Write a program to insert one row in a table –STUDENT using python-mysql connectivity and
save changes using commit() . If there is any error/exception then it should be rollback.
Q27. Write a program to access a table- Student using python-mysql connectivity. Use
fetchone(),fetchall() , fetchmany() and rowcount functions to display data.

You might also like