Fundamental and Application of
Database
? o?¨$
? o?¨$
?
B?
?
B?
? e/
?D1???ù??
? e/
?D1???ù??
?¥t
?¥t
3.6
? ÷?
=
1. ??0°?2T
z? ì
T
INSERT
INTO <V > [(<
??
1> [<
??
2>… )]
0°?
z??
|0°?2T??·?V?
??0°?2T
?
[ è 3]
?B?"pD
3¥ü (M
-i
ü2Ti?
? o b
?B?yV
CREATE TABLE Deptage
(Sdept CHAR(15) /* " */
Avgage SMALLINT) /*D
3ü (M
- */
??0°?2T
?
?=???
?
INSERT
INTO Deptage(SdeptAvgage)
SELECT SdeptAVG(Sage)
FROM Student
GROUP BY Sdept
??0°?2T
?
– INTO0 (D???HíF ?
? )
z ·?1??
? ¥V #
??
z
??
¥
¨? VDV?l?¥
¨??Bá
z
àμ·?
??
V
U1??¥
^BH??¥í
F
z ·??s
??
??¥íF?
??
|
b′
– 0°?
z SELECT0 "S
A?D INTO0 ?¥
–′¥?
?
–′¥ ??
??0°?2T
?
DBMS3????
H?_°
??íF
^
??êV
X?l¥????5
–
L8???
– ?v???
– ¨??l¥???¨??l¥???
z ?μ NOT NULL?
?¥
??
^?4
d b′
z ?μ UNIQUE?
?¥
??
^?4
d×ˉ′
z ?μ′×?
?¥
??
?4¥
??′
^?′×S?=
2. {0°?¥???
[ è ] |9
? SD"?8D
3¥??
, b
UPDATE SC
SET Grade=0
WHERE 'CS'=
(SELETE Sdept
FROM Student
WHERE Student.Sno = SC.Sno)
3. {0°?¥÷"?
[ è 11] ÷"9
? SD"
?μD
3¥ê [:
c b
DELETE
FROM SC
WHERE 'CS'=
(SELETE Sdept
FROM Student
WHERE Student.Sno=SC.Sno)
3.7
j m
jm¥+?
z′V
^VB?+?'V
j
m?¥V
zoib
jm¥?l??C
? o?
zV?¥
? ?
3M?V
jm?°?
¥
? 9
?-?M
3.7
j m
?
jm¥?T
z °?
z ÷"
z
sK÷?
z?l??
jm¥?
jm
3.7
j m
3.7.1 ?l
jm
?l
jm
3.7.2 °?
jm
3.7.3 ÷?
jm
3.7.4
jm¥T¨
1. y ?
jm
z? ì
T
CREATE VIEW
<
jm > [(<
> [<
>]…)]
AS <0°? >
[WITH CHECK OPTION]
y ?
jm
?
DBMS3? CREATE VIEW?
Ho
^ü
jm¥?li?
? 3?i?3??
¥ SELECT? b
jm°?
H?
jm¥?lV'V
?|
? ° b
F?
jm¥
??
??
??
8
{ ??
??
·?
–
8
{ :
?0°?? SELECT"S
?¥í3
F?
–
ü?·?
jm¥
?μ
:
(1) ?"S
^"f
?
Vr
T
(2) "S
1 *
(3) V ?¤
Hê
+?]
T1
jm¥3
(4) 31
jm?1?
¨?¥÷?
a¥ 3
?
0"
jm
[ è 1] y ??"D
3¥
jm b
CREATE VIEW IS_Student
AS
SELECT SnoSnameSage
FROM Student
WHERE Sdept= 'IS'
V??'V?
o
^??
'V¥t??t
=
?
y ?
jm
?
z WITH CHECK OPTION
iV
jmé?9÷??T
H?¤?ê
j
m?l?¥ìMHq
'0°??¥HqVr
T
WITH CHECK OPTION¥
jm
[ è 2] y ??"D
3¥
jmi1piV?
j
mé?¥÷??To
#?"D
3 b
CREATE VIEW IS_Student
AS
SELECT SnoSnameSage
FROM Student
WHERE Sdept= 'IS'
WITH CHECK OPTION
IS_Student
jm¥÷??T
z ???T DBMS1?F
Sdept= 'IS'¥Hq
z ÷"?T DBMS1?F
Sdept= 'IS'¥Hq
z ???T DBMS1?_° Sdept
??′
^?1 'IS'
– ?T?
^5 '????T
– ?T
àμ4 Sdept
??′51??l Sdept
1 'IS'
??V¥
jm
[ è 4] y ??"ê?
1| [?¥D
3
jm b
CREATE VIEW IS_S1(SnoSnameGrade)
AS
SELECT Student.SnoSnameGrade
FROM StudentSC
WHERE Sdept= 'IS' AND
Student.Sno=SC.Sno AND
SC.Cno= '1'
?
jm¥
jm
[ è 5] y ??"ê?
1| [?O? 90s
[
¥D
3¥
jm b
CREATE VIEW IS_S2
AS
SELECT SnoSnameGrade
FROM IS_S1
WHERE Grade>=90
{Vr
T¥
jm
[ è 6] ?lB?Q?D
3
3Mz¥
jm b
CREATE VIEW BT_S(SnoSnameSbirth)
AS
SELECT SnoSname2000-Sage
FROM Student
!?Bt?
3
??
, 9 ?1′E
--Sbirth
{Vr
T¥
jmA?
ü??lF?
jm¥ò?
??
y ?sF
jm
[ è 7] |D
3¥D|#
e¥ü (??l1B?
jm
L
! SCV? “? ”
Grade1
?3?
CREAT VIEW S_G(SnoGavg)
AS
SELECT SnoAVG(Grade)
FROM SC
GROUP BY Sno
y ?
jm
?
zB ??^ ? ¥
jm
– [ SELECT * Z
T7y¥
jm V ? ?μ
?D V?E
?
y ?
jm
?
[ è 8]| StudentV?
?μo
3:
c?l1B?
jm
CREATE VIEW
F_Student1(stdnumnamesexagedept)
AS SELECT *
FROM Student
WHERE Ssex='o '
????V Student¥2a StudentV
D F_Student1
jm¥?`1"$?ê
?á?
jm????yT b
y ?
jm
?
CREATE VIEW
F_Student2 (stdnumnamesexagedept)
AS SELECT SnoSnameSsexSageSdept
FROM Student
WHERE Ssex='o '
1V Student9F
??
???ê StudentV
D F_Student2
jm¥?`1"