You are on page 1of 6

MySQL Practical

Question 1:- Create the following Table “STUDENT” using MySQL.

Sno Name Mark


100 Hafis P A 70
102 Gokul Krishna 65
103 Althaff Moosa 70
104 Gayathri Unnikrishan 71
105 Ann Maria Saji 69

Ans: CREATE TABLE Student(Sno int primary key, Name varchar(20), Mark int);

Question 2 : Insert the above values into the table Student.

Ans:-

INSERT INTO STUDENT VALUES(100, ’Hafis P A’, 65);

INSERT INTO STUDENT VALUES(102, ’Gokul Krishna’ , 65);

INSERT INTO STUDENT VALUES(103, ‘Althaff Moosa’ ,70);

INSERT INTO STUDENT VALUES(104, ‘Gayathri Unnikrishnan’ , 71)

INSERT INTO STUDENT VALUES(105, ’Ann Maria Saji’ , 69);


Question 3 : Fetch (Display) all the details from the table STUDENT.

Ans:-

SELECT * FROM Student;

RESULT/OUTPUT:

Sno Name Mark


100 Hafis P A 70
102 Gokul Krishna 65
103 Althaff Moosa 70
104 Gayathri Unnikrishan 71
105 Ann Maria Saji 69

Question 5 : Display name and mark of all the details from the table STUDENT.

Ans:-

SELECT Name, mark FROM Student;

RESULT/OUTPUT:

Name Mark
Hafis P A 70
Gokul Krishna 65
Althaff Moosa 70
Gayathri Unnikrishan 71
Ann Maria Saji 69
Question 6 : Fetch the details of the student whose Sno is 100.

Ans:-

SELECT * FROM STUDENT WHERE Sno=100;

RESULT/OUTPUT:

Sno Name Mark


100 Hafis P A 70

Question 7 : Display name and mark of the student whose name is Altaff Moosa.

Ans:-

SELECT Name, mark FROM Student where name=’Althaff Moosa’;

RESULT/OUTPUT:

Name Mark
Althaff Moosa 70

Question 8 : Display all the details of students whose mark is greater than or
equal to 70.

Ans:-

SELECT * FROM STUDENT where mark > =70

RESULT/OUTPUT:

Sno Name Mark


100 Hafis P A 70
103 Althaff Moosa 70
104 Gayathri Unnikrishnan 71
Question 9 : Display all the details of students whose mark is greater than 70.

Ans:-

SELECT * FROM STUDENT where mark > 70

RESULT/OUTPUT:

Sno Name Mark


104 Gayathri Unnikrishnan 71

Question 10 : Write a Query to find Maximum (Highest) Mark from the table
STUDENT.

Ans:-

SELECT MAX(Mark) FROM Student;

RESULT/RESULT

MAX(Mark)
71

Question 11 : Write a Query to find Minimum (Lowest) Mark from the table
STUDENT.

Ans:-

SELECT MIN(Mark) FROM Student;

RESULT/OUTPUT

MIN(Mark)
65
Question 12 : Write a Query to find Total Mark from the table STUDENT.

Ans:-

SELECT SUM(Mark) FROM Student;

RESULT/RESULT

SUM(Mark)
345

Question 13 : Write a Query to find Average Mark from the table STUDENT.

Ans:-

SELECT AVG(Mark) FROM Student;

RESULT/OUTPUT

AVG(Mark)
69
Question 14 : Write a Query to Sort (Ascending order) table STUDENT based on
Name.

Ans:-

SELECT * FROM Student order by Name;

RESULT/OUTPUT:

Sno Name Mark


103 Althaff Moosa 16
105 Ann Maria Saji 69
104 Gayathri Unnikrishan 71
102 Gokul Krishna 65
100 Hafis P A 70

Question 15 : Write a Query to Sort (Descending order) table STUDENT based on


name

Ans:-

SELECT * FROM Student order by Name desc;

Question 16 : Write a Query to delete all the details of students whose mark is
greater than 70

DELETE FROM Student where mark > 70;

Question 17 : Write a Query to delete all the details of students.

DELETE FROM Student;

Question 18 : Delete the table student.

Ans:- DROP TABLE STUDENT;

You might also like