黑松山资源网 Design By www.paidiu.com
--创建数据库(文件:主要数据文件mdf==1,次要数据文件ndf>=0,日志文件ldf>=1)
--文件组:当1mdf,5个ndf(1,2,2),10个ldf(3,3,4),将它们分成多个组存放
CREATE database studb;
--创建表teacher,student
create table teacher ( tid int(10) primary key auto_increment, tname varchar(20), tage int(10) ); use studb;
create table student ( sid int(10) primary key auto_increment, sname varchar(20), sage int(10), tid int(10) REFERENCES teacher(tid) );
--外键约束:你问张三的老师是谁??
--select teacher.tname from teacher,student where student.sname = '张三' select t.tname from teacher t,student s where s.sname = '张三' and t.tid = s.tid
--创建课程表
create table course ( cid int(10) primary key, cname varchar(20), tid int(10) REFERENCES teacher(tid) );
--创建分数表
create table sc ( scid int(10) primary key, sid int(10) REFERENCES student(sid), cid int(10) REFERENCES course(cid), score int(10) );
--联合查询:等值查询
--1..
select c.cname from course c,student s,sc where s.sname = '小张' and s.sid = sc.sid and c.cid = sc.cid;
--2..
select sname from student s,course c,sc where c.cname='android' and sc.score>=60 and s.sid = sc.sid and c.cid = sc.cid;
--3..
--子查询:当条件也要查询的时候,我只知道学号,我不知道"小张"这个字段,那你知道小张的学号 吗
delete from sc where sid = (select sid from student where sname = '小张');
--子查询中间的符号一定是父查询与子查询两张表关联的字段(一般是主外键)
--4..
update sc set score=score+5 where cid=????; select tid from teacher where tname='李老师' ==1 select cname from course where tid = 1 ==课程名字,李老师教的 select cid from course where cname='android' ==课程ID update sc set score=score+5 where cid= ( select cid from course where cname= ( select cname from course where tid = ( select tid from teacher where tname='李老师' ) ) );
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
更新日志
2024年05月20日
2024年05月20日
- 出发吧麦芬噩兆降临之谷试炼怎么过 噩兆降临之谷阵容打法攻略
- 《黑神话:悟空》定价268元,8月20日同步上线WeGame!
- 博主称《七龙珠:电光炸裂!ZERO》或将在10月发售
- 《星期一的丰满》:新角色“热波师”变阿黑颜!?
- 张琍敏1986-群星会29[台湾版][WAV+CUE]
- 张宇《雨一直下》台首版[WAV整轨]
- 叶蕴仪1990-原宿[日本版][WAV+CUE]
- 看《庆余年2》腾讯SVIP被指VIP套娃 客服:所有用户都有广告的
- 刘畊宏脚踝受伤坐轮椅:暂时不能带大家跳操了
- 《燕云十六声》优美舞蹈幕后揭秘 国家级大师助力呈现
- 群星《2005香港高级视听展纪念大碟 SACD 》[DFF][1.9G]
- 王杰《同名精选辑》引进首版 首创[WAV+CUE][826M]
- 群星《爱情101情歌101延续篇 牵动心灵的情歌》6CD[WAV+CUE][4.2G]
- 【原神】璃月特产“人间美味”绝云椒椒的收集(58)
- 无相之草BOSS怎么打?无相草打法攻略