This repository has been archived by the owner on Jun 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
assignment-2b.sql
96 lines (75 loc) · 1.47 KB
/
assignment-2b.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
create table student (
stdID numeric(4) PRIMARY KEY,
stdName varchar2(20),
markEng numeric(3),
markMat numeric(3),
markPhy numeric(3),
check (markEng >= 0 and markEng <= 100),
check (markMat >= 0 and markMat <= 100),
check (markPhy >= 0 and markPhy <= 100)
);
insert into student values (
1002, 'Shounak', 80, 75, 50
);
insert into student values (
1003, 'Mainak', 59, 89, 92
);
insert into student values (
1001, 'Arijit', 77, 10, 81
);
insert into student values (
1005, 'Sourya', 66, 97, 80
);
insert into student values (
1004, 'Ankit', 25, 50, 70
);
--1
create view examRes as
select stdID, markEng, markMat, markPhy
from student;
--insert
insert into examRes values (
1006, 79, 84, 68
);
--update
update examRes
set markMat = 75
where
stdID = 1001;
--delete
delete from examRes
where markMat = 75;
--2
create table contact (
stdID numeric(4) PRIMARY KEY,
phone numeric(10),
city varchar2(10)
);
insert into contact values (
1003, 9876543210, 'Kolkata'
);
insert into contact values (
1005, 9876543210, 'Raiganj'
);
insert into contact values (
1004, 9463125558, 'Kohima'
);
insert into contact values (
1006, 9653214852, 'Srinagar'
);
create view newStd as
select student.stdID, stdName, phone, city
from student, contact
where student.stdId = contact.stdID;
--insert
insert into newStd values (
1001, 'Árijit', 0123456789, 'Garia'
);
--update
update newStd
set stdName = 'Shounak'
where
stdID = 1006;
--delete
delete from newStd
where city = 'Kohima';