Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

12 CS Part 2 Practical KVSC-modified

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

COMPUTER SCIENCE : XII

Practical List : (Part 2 - DBMS)


Software Used : MysQL

Write MySQL Queries to


1. (a.) To create a database KVSC_12A_2022 01-11-2022
(b.) To show the database created
(c.) To open the database.
2. (a.) Create a student table with the student id, name, class, sec, gender, stream and Total marks (out of 500).
Location as attributes where the student id is the primary key.
(b.) To show the tables.
(c.) To describe the table created
3. (a.) Insert the details of 10 students in the above table.
(b.) Write query to Display all the records.
(c.) Write query to add new column City with varchar and size as 25.
4. (a.) To delete the student whose Student id is 2020 in the above table.
(b.) To delete the student whose Student who secured marks less than 300
(c.) To show the student with marks is more than 450.
(d.) To show the student the record of all Girls students.
(e.) To show all Students whose name started with K. (Example Ketaki, Ketan etc)
(f.) To show the names of students whose marks is between 400 and 500 both inclusive and of stream as ‘Science’
5. (a.) Find the min, max, sum, and average of the marks in student table.
(b.) To find the total number of records in the table student
(c.) To display the streams available in table student.
(d.)To display the streams and total students in each stream.
(e.) To display stream and max marks stream wise.
(f.) To show the number of students who secured marks more than 400
(g.) To show name and marks of students who secured marks more than 400 in each stream

6. (a.) Find the total number of students in each section in the table
(b.) Display the Stream, Total and average marks stream wise
(c.) To show the records of students in the ascending order of marks.
(d) To show the records of students in the descending order of marks and then by student id in ascending order.
(e.) Display name, Totalmarks of students in each stream scoring highest marks.
(f.) Display name, Totalmarks of students in each section scoring marks greater than 450.
7. Compute the following:
(a.) To rounded of the value 258.7592 two places after decimal.
(b.) To rounded of the value 258.7362 two places before decimal
(c.) To find the result of 5 raise to the power 4 and square root of 144
(d.) To compute the remainder of division of 635 and 12
8. Write command in SQL to create student table as shown below. The structure of student table should be following:

a.) Add constraint NOT NULL to name field having 20 size.


b.) Update table to increase the size of class field as 3.
c.) Assign ‘F’ as default value to gender field.
d.) Insert the following records given in the table and display the records inserted.

(e.) Add new column Total marks and store total marks in all subjects.
f.) Make rollno as primary key
9. On the table created above in question no. 8 perform the following queries:
(a.) Write command to extract 5 characters of student’s name from third position as “Middle Name”. The
command should also remove all right-side spaces.
(b.) Display student’s name in upper case and corresponding no. of characters in the name from given table
(c.) Display name and the position of string ‘an’ in name column from the given table.
(d.) Write command to extract 6 characters of student’s name from right side. The command should also remove
all left-side spaces.
(e.) Write command to extract 5 characters of student’s name from 4th position. The command should also
remove leading and trailing spaces.
(f.) Write command to display name and join class and section as class and section
(g.) Write query to create a string from ASCII Code values as
1.) 70,65,67,69
2.) 71,79,79.3,68
(h.) Display name with total marks of all students in the format
<Name> ‘ has scored total marks – ‘ <total marks>
(i.) What will be the result of the given query:
SELECT LENGTH(LTRIM(SUBSTR(name,5)));
10. Queries on Date Function
a) Display current date and time.
b) Display name of month for date of birth column.
c) Display date of birth after increasing 10 days in it.
d) Extract the date from current date and time
e) Display Date , Name of Month and Year from Date of birth as ‘Date’, ‘Monthname’ and ‘Year’ respectively.
f) Display date, day and day name from date of birth column.

11. (a.) Display average marks of all the students till 02 decimal places. The column name should be “Average Marks”.
(b.) Display gender, and their maximum and minimum total marks based on each gender.
(c.) Display class and average marks of class 11 and 12.
(d.) Display Class and no of male and females in each class.
(e.) Display subject and average marks in each subject whose marks is greater than 75.
12. Write the SQL query commands based on following tables :

Write SQL query :


(i) To display the details of all workers in descending order of DOB
(ii) To display Name , Designation and Pay of those workers whose PLEVEL is either P001 or P002.
(iii) To display the content of workers of youngest employee.
(iv.) To display PLevel and number of employees in each level of employees whose pay > 25000.
(v.) To display level, name , pay and designation of employees who are getting allowance.

13. Write a program to Integrate SQL with Python by importing the MySQL
module record of employee and display the record.
OUTPUT

***********

You might also like