Term 2 Practical File SQL
Term 2 Practical File SQL
Query:
PROGRAM 2
Write a SQL query to create a Student table with the student id, Rno, class section,
gender, name, dob and marks as attributes where the student Id is the primary key.
Query:
CREATE TABLE Student(StudentID int primary key ,Rno int,Class int ,Section char ,Gender
char,Name varchar(20),DOB date, Marks float);
Output:
PROGRAM 3
Write a SQL query to insert the details of at least 10 students in the above table.
Query:
INSERT INTO Student VALUES(16171,1, 11, "A", "M", "Shyam", '2004-12-22', 96),
(16172,13, 10, "B", "F", "Priya", '2006-07-04', 50), (16173,15, 12, "D", "M", "Rahul",
'2005-03-14', 62), (16174,10, 11, "A", "M", "Vivkey", '2007-07-24', 99), (16175,21, 10,
"C", "F", "Ranjeet", '2005-11-11', 72),(16176,25, 11, "A", "M", "John", '2006-01-20',
45), (16177,7, 12, "B", "F", "Goerge", '2003-01-04', 73), (16178,20, 11, "C", "M",
"Luffy", '2005-05-10', 63),(16179,17, 11, "A", "M", "Mohan", '2007-05-10', 84),
(16180,26, 10, "D", "F", "Arlo", '2007-05-10', 69);
PROGRAM 4
Write a SQL query to delete detail of particular student in the above table.
Query:
Output:
PROGRAM 5
Write a SQL Query to increase marks by 5% for those students who have Rno more than
20.
Query:
PROGRAM 6
Write a SQL Query to display the entire content of the student table.
Query:
Output:
PROGRAM 7
Write a SQL Query to display Rno, Name and Marks of those students who are
scoring marks more than 50.
Query:
Select Rno, Name , Marks from Student Where Marks > 50;
Output:
PROGRAM 8
Write a SQL Query to find the average of marks from the student table.
Query:
Output:
PROGRAM 9
Write a SQL Query to find the number of students, who are from section ‘A’.
Query:
Output:
PROGRAM 10
Write a SQL Query to add a new column email in the above table with appropriate
data type.
Query:
Alter Table Student Add column emailID char(20); Select* from Student;
Output:
PROGRAM 11
Write a SQL Query to add the email ids of each student in the previously created
email column.
Query:
Select*From Student;
Output:
PROGRAM 12
To display the information of all the students, whose name starts with ‘An’.
Query:
Output:
PROGRAM 13
Write a SQL to display Rno, Name , DOB of those students who were between ‘2005-01-
01’ and ‘2005-12-31’.
Query:
Select Rno, Name, DOB from Student Where DOB Between '2005-01-01' and '2005-
12-31';
Output:
PROGRAM 14
Write a query to display Rno, Name , DOB, Marks, email of those male students in
ascending order of their names.
Query:
Select Rno, Name, DOB, Marks, emailID from Student where Gender = 'm' order by
Name asc;
Output:
PROGRAM 15
Write a SQL query to display Rno, Gender, Name, DOB, Marks, email in desc order of their
mark.
Query:
Select Rno, Gender, Name, DOB, Marks, emailID from Student order by Marks desc;
Output:
PROGRAM 16
Query:
Output:
PROGRAM 17
Write a SQL Query to show min, max and sum of the marks of student table.
Query:
Output:
Output:
Output:
PROGRAM 18
Create a table named WORKER with column Ecode,Name, Desig, PLevel, DOJ and
DOB.
Query:
CREATE TABLE WORKER (ECODE INT PRIMARY KEY, NAME CHAR(25),DESIG CHAR(30),
Output:
PROGRAM 19
Write a SQL query to insert any five records in table worker of your choice.
Query:
Output:
PROGRAM 20
Output:
Output:
(iii) SELECT * FROM WORKER WHERE DOB BETWEEN ’19-JAN-1984’ AND ’18-JAN-
1987’;
Output:
Output:
S.No PROGRAMS Signature
1. Write a SQL query to create a database.
2. Write a SQL query to create a Student table with the student id, Rno,
class section, gender, name, dob and marks as attributes where the
student Id is the primary key.
3. Write a SQL query to insert the details of at least 10 students in the
above table.
4. Write a SQL query to delete detail of particular student in the above
table.
5. Write a SQL Query to increase marks by 5% for those students who
have Rno more than 20.
6. Write a SQL Query to display the entire content of the student table.
7. Write a SQL Query to display Rno, Name and Marks of those students
who are scoring marks more than 50.
8. Write a SQL Query to find the average of marks from the student table.
9. Write a SQL Query to find the number of students, who are from
section ‘A’.
10. Write a SQL Query to add a new column email in the above table with
appropriate data type.
11. Write a SQL Query to add the email ids of each student in the
previously created email column.
12. To display the information of all the students, whose name starts with
‘An’.
13. Write a SQL to display Rno, Name , DOB of those students who were
between ‘2005-01-01’ and ‘2005-12-31’.
14. Write a query to display Rno, Name , DOB, Marks, email of those male
students in ascending order of their names.
15. Write a SQL query to display Rno, Gender, Name, DOB, Marks, email in
desc order of their mark.
16. Write a SQL Query to display unique section available in the table.
17. Write a SQL Query to show min, max and sum of the marks of student
table.
18. Create a table named WORKER with column Ecode,Name, Desig,
PLevel, DOJ and DOB.
19. Write a SQL query to insert any five records in table worker of your
choice.
20. Write SQL commands for the various statements
GOVT. CO-ED SR. SEC. SCHOOL,
A6 BLOCK, PASCHIM VIHAR, DELHI-110063
INFORMATICS PRACTICES
PRACTICAL FILE
12th – A
SUBMITTED BY:- Ankit Kumar Sharma(09)
SUBMITTED TO:- Manisha Mam(PGT CS)