|
ѧÉú±ísid,sname,³É¼¨±ícid,cname,ѧÉú³É¼¨±ísid,cid,cscore,ÒªÇóÊä³öÌØµØ¿¼Éú×î¸ß³É¼¨µÄ¿Î³ÌÃû³Æ
|
--1¡¢½¨±íSQL:
--ѧÉú±í£º
-- Createtable
createtable STUDENT
(
SID NUMBERnotnull,
SNAME NVARCHAR2(40)
)
tablespace CABLESCD
pctfree10
initrans1
maxtrans255
storage
(
initial64
minextents1
maxextentsunlimited
);
--³É¼¨±í
-- Createtable
createtable SCORE
(
CID NUMBERnotnull,
CNAME NVARCHAR2(40) notnull
)
tablespace CABLESCD
pctfree10
initrans1
maxtrans255
storage
(
initial64
minextents1
maxextentsunlimited
);
--ѧÉú³É¼¨±í
-- Createtable
createtableSTUDENGSCORE
(
SID NUMBERnotnull,
CID NUMBERnotnull,
CSCORE NUMBER(4,2)
)
tablespace CABLESCD
pctfree10
initrans1
maxtrans255
storage
(
initial64
minextents1
maxextentsunlimited
);
--2¡¢²åÈëSQLÓï¾ä£º
insert into student
(sid, sname)
values
(001,'ZHAOHY');
insert into student
(sid, sname)
values
(002, 'ZHANGQL');
insert into student
(sid, sname)
values
(003, 'ZHAOHB');
insert into score
(cid, cname)
values
(100, 'Êýµç');
insert into score
(cid, cname)
values
(200, 'Ä£µç');
insert into score
(cid, cname)
values
(300, 'Ó¢Óï');
insert into score
(cid, cname)
values
(400, 'ÕþÖÎ');
select * from score
(001, 100, '60');
insert into studengscore
(sid, cid, cscore)
values
(002, 100, '70');
insert into studengscore
(sid, cid, cscore)
values
(003, 100, '80');
insert into studengscore
(sid, cid, cscore)
values
(003, 200, '90');
insert into studengscore
(sid, cid, cscore)
values
(003, 300, '99');
insert into studengscore
(sid, cid, cscore)
values
(003, 400, '98');
select * from studengscore
--3¡¢²éѯSQL
select * fromstudengscore;
select * from student;
select * from score;
select cnamefrom score where cid =(select cid fromstudengscore wherecscore=(
selectmax(cscore) fromstudengscore where sid=3 ));

|
|