免费预览已结束,剩余6页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
CREATE DATABASE 库存管理goUSE 库存管理GOCREATE TABLE 仓库(仓库号 CHAR(5) PRIMARY KEY,城市 CHAR(10),面积 INT CHECK(面积0)GOCREATE TABLE 职工(仓库号 CHAR(5) FOREIGN KEY REFERENCES 仓库,职工号 CHAR(5) PRIMARY KEY,工资 INT CHECK(工资=1000 AND 工资=5000) DEFAULT 1200)GOCREATE TABLE 供应商(供应商号 CHAR(5) PRIMARY KEY,供应商名 CHAR(20),地址 CHAR(20)GOCREATE TABLE 订购单(职工号 CHAR(5) NOT NULL FOREIGN KEY REFERENCES 职工,供应商号 CHAR(5) NULL FOREIGN KEY REFERENCES 供应商,订购单号 CHAR(5) PRIMARY KEY,订购日期 DATETIME DEFAULT GetDate()GOINSERT INTO 仓库 VALUES(WH1,北京,370)INSERT INTO 仓库 VALUES(WH2,上海,500)INSERT INTO 仓库 VALUES(WH3,广州,200)INSERT INTO 仓库 VALUES(WH4,武汉,400)GOINSERT INTO 职工 VALUES(WH2,E1,1220)INSERT INTO 职工 VALUES(WH1,E3,1210)INSERT INTO 职工 VALUES(WH2,E4,1250)INSERT INTO 职工 VALUES(WH3,E6,1230)INSERT INTO 职工 VALUES(WH1,E7,1250)GOINSERT INTO 供应商 VALUES(S3,振华电子厂,西安)INSERT INTO 供应商 VALUES(S4,华通电子公司,北京)INSERT INTO 供应商 VALUES(S6,607厂,郑州)INSERT INTO 供应商 VALUES(S7,爱华电子厂,北京)GOINSERT INTO 订购单 VALUES(E3,S7,OR67,2002-06-23)INSERT INTO 订购单 VALUES(E1,S4,OR73,2002-07-28)INSERT INTO 订购单 VALUES(E7,S4,OR76,2002-05-25)INSERT INTO 订购单 VALUES(E6,NULL,OR77,NULL)INSERT INTO 订购单 VALUES(E3,S4,OR79,2002-06-13)INSERT INTO 订购单 VALUES(E1,NULL,OR80,NULL)INSERT INTO 订购单 VALUES(E3,NULL,OR90,NULL)INSERT INTO 订购单 VALUES(E3,S3,OR91,2002-07-13)GOselect *from 仓库select *from 职工select *from 订购单select *from 供应商 select 供应商名 from 供应商 where 地址=北京 select 订购单号 from 订购单 where 供应商号=S6 select *from 订购单 where 职工号=E6and 供应商号=S6 select 职工号,仓库号 from 职工 where 职工号 in( select 职工号 from 订购单 where 供应商号=S3) select *from 职工 where 职工号 not in ( select 职工号 from 订购单 where 供应商号 =S3) select *from 供应商 where 供应商号 not in ( select 供应商号 from 订购单 where 供应商号 is not null) select *from 供应商 where 地址=北京 and 供应商号 in ( select 供应商号 from 订购单 where 职工号 = E1)and 供应商号 in ( select 供应商号 from 订购单 where 职工号 =E3) select 工资 from 职工 where 职工号 in( select 职工号 from 订购单 A where 供应商号 in (select 供应商号 from 供应商 where 供应商名=华通电子公司) select 供应商名 from 供应商 where 供应商号 not in( select 供应商号 from 订购单 where 供应商号 is not null and 职工号 in( select 职工号 from 职工 where 工资1230) select count(distinct 仓库号)from 仓库 select*from 仓库 where 面积 =(select (max) 面积 from 仓库) select avg(面积) 平均面积 from 仓库 select avg(面积)from 仓库 where 仓库号 in ( select 仓库号 from 职工 where 职工号 in ( select 职工号 from 订购单 where 供应商号 =s4) select 地址, count (distinct 供应商号) from 供应商 group by 地址 select 仓库号,count(distinct 职工号 )from 职工 where 工资 1220 group by 仓库号 select count( distinct 供应商号)from 订购单 where 职工号 in ( select 职工号 from 职工 where 仓库号 in ( select 仓库号 from 仓库 where 面积 =( select min ( 面积)from 仓库) select count( distinct 供应商号)from 订购单 where 职工号 in ( select 职工号 from 职工 where 仓库号 in ( select 仓库号 from 仓库 where 面积 = all ( select 面积 from 仓库) select *from 职工 X where 工资 21 select sname from s where not exists ( select *from c where teacher=程军and not exists( select*from sc where s.s#=sc.s# and sc.c#=c.c#) select c# from c where c# not in ( select c# from sc where s# in ( select s# from s where sname =李强) select c# from c where not exists ( select*from sc where c.c#=sc.c# and s# in ( select s# from s where sname = 李强) select distinct x.s# from sc x,sc y where x.s#=y.s# and x.c# !=y.c# select s# from sc group by s# having count(*)=2 select c#,cname from c where not exists ( select * from s where not exists( select *from sc where s.s#=sc.s# and c.c# =sc.c#) select distinct s# from sc where c# in ( select c# from c where teacher =程军) select x.s# from sc x,sc y where x.s# =y.s# and x.c#=c1and y.c#=c5 select s# from s where s# in ( select s# from sc where c#=c1)and s# in( select s# from sc where c#=c5) select sname from s where not exists( select*from c where not exists( select*from sc where sc.c#=c.c# and sc.s#=s.s#) select s# from s where not exists( select*from sc x where s#=s2and not exists( select*from sc y where s.s#=y.s# and x.c#=y.c#) select s#,sname from s where s# in( select s# from sc where c# in( select c# from c where cname=c语言) select s#,sname from s where s# not in( select s# from sc where c# in( select c# from c where cname=c语言) select s#, count(distinct c#)as 选课门数 ,avg(grade)as 平均分,max(grade)as 最高分,min(grade)as 最低分 from sc group by s# select cname from c where not exists( select *from s where sex =男and not exists( select *from sc where s.s#=sc.s# and c.c#=sc.c#) select s#,sname from s where exists( select s# from sc x where s.s#=x.s# and exists( select s#,min(grade) from sc y where x.s#=y.s# group by s# having min(grade)80) select s#,sname from s where s# not in( select s# from sc where s.s#=sc.s# and grade =all( select count(distinct c#) from sc group by s#) select s#,sname from s where s# not in ( select s# from sc x where grade 60 group by s# having count(distinct c#)=2) select cname,teacher from sc,c where sc.c#=c.c# and s#=s1 select sname from s,sc,c where sc.c#=c.c# and sc.s#=s.s# and sex =女and teacher like 王% select sname from s where sex=女and s# in( select s# from sc where c# in( select c# from c where teacher like王%) select sname from s where sex =女and exists( select*from sc where s.s#=sc.s# and exists( select*from c where sc.c#=c.c# and teacher like王%) select cname from c where c# not in( select c# from s,sc where s.s#=sc.s# and sc.c#=c.c# and sname like王%) select cname from c where not exists( select * from s,sc where s.s#=sc.s# and sc.c#=c.c# and sname like王%) select d
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 山东菏泽中医师承确有专长人员考核考试题含答案2024年
- 2025年金融科技产品创新应用可行性研究报告及总结分析
- 2025年个性化营养食品研发项目可行性研究报告及总结分析
- 2025年企业碳信息披露承诺协议
- 2025年基于大数据的商业决策支持系统可行性研究报告及总结分析
- 在建工程项目合同台账(3篇)
- 园林绿化工程合同协议书(3篇)
- 中国地质大学校长办公室文件
- 阿里巴巴电子商务平台应用专员考试
- 2024上海虹口区中小学教师招聘考试真题及答案
- 2025年超星尔雅学习通《数据仓库与数据挖掘》考试备考题库及答案解析
- 新入职护士岗前培训
- 2025年全国中学生历史竞赛试题及答案解析
- 老年鼻饲患者护理
- 人事管理岗位竞聘陈述
- 互感器安装施工方案
- 制片人手册2023版制品人手册
- 二次元作业指导书
- SB/T 10595-2011清洁行业经营服务规范
- 证监会专业科目考试复习资料
- 联合收获机结构与维修课件
评论
0/150
提交评论