create table stu
(
Sno varchar(30)primary key,
Sname varchar(30),
Ssex char(10),
Sage int,
Sdept varchar(30),
address varchar(30),
borndate varchar(30)
)
insert into stu values('110','王二','男',22,'计算机系','广州市天河区','1992-01-01')
insert into stu values('111','李四','男',22,'计算机系','广州市桥东区','1992-01-01')
insert into stu values('112','李小林','女',22,'计算机系','广州市桥东区','1992-01-01')
insert into stu values('113','温月','男',22,'计算机系','广州市天河区','1992-01-01')
insert into stu values('114','李德华','男',22,'计算机系','广州市天河区','')
create table Course
(
Cno varchar(10) primary key,
Cname varchar(20) UNIQUE,
Tname varchar(20)
)
insert into Course values('C01','SQL2008数据库','王文海')
insert into Course values('C02','JAVA编程','柳大华')
insert into Course values('C03','安卓开发','胡玉玉')
create table xk
(
Sno varchar(30),
Cno varchar(10),
Grade Float
)
insert into xk values('110','C01',88)
insert into xk values('111','C02',55)
insert into xk values('112','C03',78)
insert into xk values('113','C01',89)
insert into xk values('114','C02',65)
insert into xk values('110','C02',85)
insert into xk values('111','C03',77)
insert into xk values('112','C02',59)
insert into xk values('113','C03',99)
insert into xk values('114','C01',84)
--(1)
SELECT * FROM STU WHERE Sname LIKE '李%'
--(2)
SELECT COUNT(SNO) FROM xk WHERE Grade<60
--(3)
SELECT * FROM stu WHERE borndate=''
--(4)
SELECT S.SNAME,S.Sdept,X.Grade FROM STU S,xk X WHERE S.Sno = X.Sno AND 80<=X.Grade and X.Grade<=100
--(5)自己信息按照下面自己改下就可
insert into stu values('115','肖玉玉','女',22,'计算机系','广州市天河区','1992-01-01')
--(6)
SELECT * FROM stu WHERE address NOT LIKE '%桥东区%' AND Ssex='男'
--(7)
SELECT AVG(Grade) FROM xk WHERE Cno='C01'
--(8)
SELECT CNAME,Grade FROM Course ,xk WHERE Course.Cno = xk.Cno AND xk.Sno = (SELECT Sno from stu WHERE SNAME = '温月')
--(9)
update Course set Tname = '李文海' where Tname = '王文海'
--(10)
SELECT * INTO 女生表 FROM stu WHERE Ssex='女'
--(11)
CREATE NONCLUSTERED INDEX IX_name
ON STU(SNAME)
WITH FILLFACTOR = 75
GO
--(12)
create view V_xs
as
SELECT S.SNO,S.SNAME,S.Sdept,X.Cno ,X.Grade FROM stu S,xk X WHERE S.SNO = X.SNO AND S.Ssex='女' and s.Sname like '王%';
--(13)
BEGIN
WAITFOR DELAY '00:05';
select * from V_xs ;
END;
--(14)
create trigger cfq_kc
on stu
for delete
as
begin
DELETE XK where Sno=(select SNO from deleted)
end
--(15)
create procedure proc_cj
@cname varchar(20)
as
BEGIN
declare @sql varchar(1000)
select TOP 2 s.SNO,S.SNAME,S.Sdept,@cname,X.Grade from stu S,XK X where S.Sno = X.Sno AND X.Cno = (SELECT Cno FROM Course WHERE Cname = @cname) ORDER BY X.Grade
END
execute proc_cj 'JAVA编程'
已测,这些题都很简单的,另外我用的数据库是SQL2008,如果楼主用的是其他数据库的话就可能要改一些了,自己多多努力一下并不是很难,实现的过程是非常有趣的。
这些都是写基础。你应该自己做。
10RMB帮你搞定如何?