首页 热点资讯 义务教育 高等教育 出国留学 考研考公

两题sql程序作业,求高人指点,sql server

发布网友

我来回答

1个回答

热心网友

表没问题,刚才我都跑了一遍
你问题的两个结果,第一个没问题,第二个没测试,但是创建成功,有问题自己调试一下吧

1
select c.cn,s.sno,s.sn from
s,c,sc where s.sno=sc.sno and c.CNO=sc.cno and c.CNO in
(select cno from tc where tno=(select tno from t where tn='张兰'))

2
Create Trigger tcno
On C
for Update
As
if Update(CNO)
begin
Update TC Set CNO=i.CNO From TC ,Inserted i Where TC.CNO=i.CNO
Update SC Set CNO=i.CNO From SC ,Inserted i Where SC.CNO=i.CNO
end追问CREATE TABLE S (A1 char(2) not null , A2 tinyint, A3 money)

语句建表的话 A1设为主键 A2默认值为1 在上面的基础上麻烦帮我改一下
还有A1后面还用不用加not null?

追答CREATE TABLE S (a1 char(2) not null primary key,
a2 tinyint not null default 1,
a3 money)
有主键必须not null
比如a3那种就可有可无了

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com