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

Ex 6

jvvbjc

Uploaded by

asaithambiasdf71
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)
5 views3 pages

Ex 6

jvvbjc

Uploaded by

asaithambiasdf71
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

6. Develop sql queries to create a views and expand it.

mysql> use student;

mysql>CREATE TABLE Student_Details (Stu_ID INT Primary Key,


Stu_Name VARCHAR(50), Stu_Subject VARCHAR(50), Stu_Marks INT);

mysql>INSERT INTO Student_Details (Stu_ID, Stu_Name, Stu_Subject, Stu _Marks)


VALUES (1001, ‘Akhil’, ‘Maths’, 85), (1002, ‘Balram’, ‘Science’, 78),
(1003, ‘Baskar’, ‘Maths’, 87), (1004, ‘Cheran’, ‘English’, 95),
(1005, ‘Diksha’, ‘Hindi’, 99), (1006, ‘Raman’, ‘Computer’, 90),
(1007, ‘Sheela’, ‘Science’, 68);

mysql> SELECT * from Student_Details;

mysql> CREATE VIEW Student_View AS SELECT Stu_ID, Stu_Subject, Stu_Marks


FROM Student_Details WHERE Stu_Marks > 85;

mysql> SELECT * from Student_View;


a) Update a View

mysql> CREATE OR REPLACE VIEW Student_View AS


SELECT Stu_ID, Stu_Name, Stu_Subject, Stu_Marks
FROM Student_Details WHERE Stu_Subject = 'Maths';

mysql> SELECT * from Student_View;

b) Insert new record in the View

mysql> INSERT INTO Student_View (Stu_ID, Stu_Subject, Stu_Marks)


VALUES (1008, ‘Hindi’, 89);

mysql> SELECT * from Student_View;

c) Delete the record from the View


mysql> DELETE FROM Student_View WHERE Stu_Subject = 'Maths';

mysql> SELECT * from Student_View;

d) Drop a View

mysql> DROP VIEW Student_View;

You might also like