
5个回答
展开全部
这个是关系图,你看到两个方框中间有一条直线相连了么??那是因为有一个外键的存在,所以你不能去删除那个从属表,也就是你的ST表,想删除的话 一定要先删除外键!具体的呢点击右键在设计模式里找一下!
祝你成功 加油!
祝你成功 加油!
展开全部
外键 最多只能设置成:
删除 主表 的数据时, 关联删除 子表的 相关数据。
至于把表 DROP 了, 同时 DROP 掉另外一个表,好像外键不干这个事情。
SQL Server 外键约束的例子
http://hi.baidu.com/wangzhiqing999/blog/item/969f70fa84e2873e5d600821.html
删除 主表 的数据时, 关联删除 子表的 相关数据。
至于把表 DROP 了, 同时 DROP 掉另外一个表,好像外键不干这个事情。
SQL Server 外键约束的例子
http://hi.baidu.com/wangzhiqing999/blog/item/969f70fa84e2873e5d600821.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1. 使用标准SQL嵌套语句查询选修课程名称为’税收基础’的学员学号和姓名
select s#,sn from s where s# in (select s# from sc where c#=(select c# from c where cn='税收基础'))
2. 使用标准SQL嵌套语句查询选修课程编号为’C2’的学员姓名和所属单位
select sn,sd from s where s# in (select s# from sc where c#='C2')
3. 使用标准SQL嵌套语句查询不选修课程编号为’C5’的学员姓名和所属单位
select sn,sd from s where s# not in (select s# from sc where c#='C5')
4. 使用标准SQL嵌套语句查询选修全部课程的学员姓名和所属单位
select sn,sd from s where s# in (select s# from sc where c# = all(select c# from c) group by s#)
5. 查询选修了课程的学员人数
select count(distinct s#) from SC
6. 查询选修课程超过5门的学员学号和所属单位
select s#,sd from s where s# in (select s# from sc group by s# having count(*)>5)
3. 使用标准SQL嵌套语句查询不选修课程编号为’C5’的学员姓名和所属单位
select sn,sd from s where s# not in (select s# from sc where c#='C5')
s#改成sn 不就可以了
select s#,sn from s where s# in (select s# from sc where c#=(select c# from c where cn='税收基础'))
2. 使用标准SQL嵌套语句查询选修课程编号为’C2’的学员姓名和所属单位
select sn,sd from s where s# in (select s# from sc where c#='C2')
3. 使用标准SQL嵌套语句查询不选修课程编号为’C5’的学员姓名和所属单位
select sn,sd from s where s# not in (select s# from sc where c#='C5')
4. 使用标准SQL嵌套语句查询选修全部课程的学员姓名和所属单位
select sn,sd from s where s# in (select s# from sc where c# = all(select c# from c) group by s#)
5. 查询选修了课程的学员人数
select count(distinct s#) from SC
6. 查询选修课程超过5门的学员学号和所属单位
select s#,sd from s where s# in (select s# from sc group by s# having count(*)>5)
3. 使用标准SQL嵌套语句查询不选修课程编号为’C5’的学员姓名和所属单位
select sn,sd from s where s# not in (select s# from sc where c#='C5')
s#改成sn 不就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
外键和主键之间有个级联删除选项。设置了,当你删除主键记录的时候外键的记录才会删除。http://blog.163.com/chen_zhen_zhu/blog/static/1339459332009112425149338/
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这说明主外键关系没有做好。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询