急:关于数据库的问题,急解答。
发布网友
发布时间:2022-04-23 23:56
我来回答
共1个回答
热心网友
时间:2023-07-14 05:40
第一题:
CREATE FUNCTION func_学生信息( @sex char(2),@dept varchar(8))
RETURNS table
as
return(
select sno,sn,sex, dept
from s
where sex=@sex and dept=@dept)
对应例子:declare @sex char(2),@dept varchar(8)
set @sex ='男'
set @dept='IS'
select * from func_学生信息(@sex,@dept)
第二题:
create proc max_z( @i int,@j int,@max int output)
as
if (@i>@j)
set @max=@i
else
set @max=@j
select @max as '最大值'
对应例子:declare @ii int ,@jj int,@maxx int
exec max_z 80,120, @maxx output
第三题:
create trigger course_delete
on course
after delete
as
if exists(select * from sc where cno=(select cno from deleted))
rollback
对应例子:delete
from c
where cno='c6'
第四题:
use basetest
select sc.sno,sn,cn,score
from s,c,sc
where s.sno=sc.sno and c.cno=sc.cno and dept='IS'
第五题:
select s.*
from s
where age<(select min(age)
from s
where dept='IS')
and (dept<>'IS')
第六题:
select sno,count(cno) as 选课门数
from sc
where cno is not null
group by sno