




已阅读5页,还剩9页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1)找出 MGM studios 的地址。select 地址 from 制片公司where 公司名称=MGM studios2)找出 Sandra Bullock 的出生日期。select 生日from 电影明星where 姓名=Sandra Bullock3)找出在2003年拍摄过电影的所有影星,或者拍摄过电影中含有天空的电影的所有明星。select 演员姓名from 演员参演电影where 拍摄年份=2003 or 电影名称 like%天空%4)找出净资产至少1000万美元的所有行政长官。select 姓名from 制片人与行政总裁where 资产=100000005)找出所有的男影星或者是住址中含有 Malibu 的影星。select 姓名from 电影明星where 地址 like Malibu or 性别 like 男1)电影加勒比海盗4中的男影星都有谁。select 姓名from 电影明星where 性别 =男 and 姓名 in(select 演员姓名from 演员参演电影where 电影名称=加勒比海盗4)2)谁是米高梅制片公司的总裁。select 姓名from 制片人与行政总裁where 身份证号 =(select 行政总裁from 制片公司where 公司名称 =MGM studios)4)那些电影比乱世佳人更长。select 电影名称from 电影where 长度 (select 长度from 电影where 电影名称 = 乱世佳人)5)那些行政长官比 Tom 更富有。select 姓名from 制片人与行政总裁where 资产(select 资产from 制片人与行政总裁where 姓名=Tom)1、找出价格低于6000元的PC计算机型号、速度、以及硬盘容量。select 型号,速度,硬盘容量from PC电脑where 价钱 60002、同上要求,另外将 速度 改名为 兆赫,将 硬盘 改名为 G字节。select 型号,速度 兆赫,硬盘容量 G字节from PC电脑where 价钱 60005、从打印机关系中找出所有彩色打印机的元组。select *from 打印机where 是否彩色 = 是6、找出具有300GB以上的硬盘容量而价格低于2000元的所有个人计算机的型号、速度及硬盘。select 型号,速度,硬盘容量from PC电脑where 硬盘容量300 and 价钱 3002、找出由生产厂商苹果生产的所有产品的型号和价格。select 型号,价钱from PC电脑where 型号 in(select 产品型号from 产品where 制造商=苹果)unionselect 型号,价钱from 便携式电脑where 型号 in(select 产品型号from 产品where 制造商=苹果)unionselect 型号,价钱from 打印机where 型号 in(select 产品型号from 产品where 制造商=苹果)3、找出所有出售便携式电脑(而不出售PC)的生产厂商。select 制造商from 产品where 产品类型 LIKE 便携式电脑 and 制造商 not in(select 制造商from 产品where 产品类型 LIKE PC电脑 or 产品类型 LIKE 打印机)4、找出在两种或两种以上PC上出现的硬盘容量。select 硬盘容量from PC电脑group by 硬盘容量having count(*)=25、找出拥有相同速度和内存的PC的成对的型号。select distinct Q.型号,P.型号from PC电脑 Q, PC电脑 Pwhere Q.速度=P.速度 and Q.内存=P.内存 and Q.型号=1500)2、找出价格最高的打印机。(注意 all 和 any 的区别) (=all和=max()select 型号from 打印机where 价钱 =all(select 价钱from 打印机)3、找出速度低于任何PC的便携式电脑。(注意all和any的区别)select 型号from 便携式电脑where 速度 all(select 速度from PC电脑)4、找出具有最高价格的机器(PC,便携式电脑或打印机)的型号。select 型号from PC电脑where 价钱=(select MAX(价钱)from PC电脑)unionselect 型号from 便携式电脑where 价钱=(select MAX(价钱)from 便携式电脑)unionselect 型号from 打印机where 价钱=(select MAX(价钱)from 打印机)5、找出具有最低价格的彩色打印机的制造商。(=any和in =all和MIN()select 制造商from 产品where 产品型号 =any(select 型号from 打印机where 价钱=all(select 价钱from 打印机where 是否彩色 =是)6、找出在具有最小内存容量的所有 PC 中,具有最快处理器的 PC 制造商。select 制造商from 产品where 产品型号 =any(select 型号from PC电脑where 速度 =(select MAX(速度) from PC电脑where 内存=all(select 内存from PC电脑)and 内存 in(select min(内存)from pc电脑)select 制造商from 产品where 产品型号 in(select 型号from PC电脑where 速度=(select MAX(速度)from PC电脑where 内存=(select MIN(内存)from PC电脑)and 内存 in(select MIN(内存)from pc电脑)select 制造商from 产品,PC电脑where 产品.产品型号=PC电脑.型号 andPC电脑.速度=(select MAX(速度)from PC电脑where 内存133 and 产品类型 LIKE PC电脑 or 产品类型 LIKE 便携式电脑 and 制造商 in(select min(制造商)from vproductgroup by 制造商having COUNT(产品型号)=2)3、找出生产最高速度的计算机(PC电脑或便携式电脑)厂商。select distinct 制造商from vproductwhere 速度133 and 产品类型 LIKE PC电脑 or 产品类型 LIKE 便携式电脑 and 制造商 in(select min(制造商)from vproductgroup by 制造商having COUNT(产品型号)=2)create view 最高速度1asselect distinct 制造商from 产品,PC电脑where 产品.产品型号=PC电脑.型号and 速度=(select MAX(速度)from PC电脑)unionselect distinct 制造商from 产品,便携式电脑where 产品.产品型号=便携式电脑.型号and 速度=(select MAX(速度)from 便携式电脑 )4、找出至少生产三种不同速度 PC的厂商。select distinct 制造商from vproductwhere 产品类型 LIKE PC电脑 and 制造商 in (select min(制造商) from vproduct group by 产品类型 having count(速度)=3)5.找出只卖三种不同型号的PC的厂商。create view 三种asselect 制造商from 产品 A where A.产品型号=any(select 型号from PC电脑 )AND A.制造商 not in (select B.制造商from 产品 Bwhere 产品类型=便携式电脑 or 产品类型=打印机 )GROUP BY 制造商having count(*)=3create view vproduct3(制造商,产品型号,产品类型)asselect 制造商,产品型号,产品类型from 产品where 制造商 not in(select 制造商 from 产品 where 产品类型 LIKE 便携式电脑 or 产品类型 LIKE 打印机)select 制造商from vproduct3group by 制造商having count(产品型号)=2select avg(速度)from PC电脑select avg(速度)from 便携式电脑where 价钱2500select avg(价钱)from PC电脑where 型号 in(select 产品型号from 产品 where 制造商=A)实验六1)找出PC的平均速度。select AVG(速度)from vproduct3 where 产品类型=PC电脑2)找出价格超过2500美元的便携式电脑的平均速度。select AVG(速度)from vproduct3where 产品类型=便携式电脑 and 价钱25003)找出厂商A生产PC的平均价格。select AVG(价钱)from vproduct3where 制造商=A and 产品类型=PC电脑4)找出厂商D生产的PC和便携式电脑的平均价格。select AVG(价钱)from vproduct3where 制造商=D(5)找出各种不同速率的pc的平均价格create view fiveasselect 价钱,速度from PC电脑select 速度,AVG(价钱) as 平均价钱from fivegroup by 速度直接查询select 速度,AVG(价钱)from PC电脑group by 速度6)找出各厂商生产的便携式电脑的显示器平均尺寸。create view vproduct4(制造商,产品型号,速度,价钱,屏幕大小)asselect 制造商,产品型号,速度,价钱,屏幕大小from 产品,便携式电脑where 产品.产品型号=便携式电脑.型号select 制造商,AVG(屏幕大小)from vproduct4group by 制造商7)找出生产三种不同型号的PC的厂商。create view vproduct5(制造商,产品型号,产品类型,价钱)asselect 制造商,产品型号,产品类型,价钱from 产品,PC电脑 where 产品.产品型号=PC电脑.型号select 制造商from vproduct5group by 制造商having count(产品型号)=38)找出各厂商生产的PC的最高价格。select 制造商,MAX(价钱)from vproduct5group by 制造商9)找出速度超过150MHz的各种速度的PC的平均价格。select AVG(速度)from vproduct3where 产品类型=PC电脑 and 速度15010)找出所有生产打印机的厂商生产PC的硬盘平均容量。create view nowasselect 制造商,产品型号from 产品where 制造商 in(select 制造商 from 产品where 产品类型=打印机)and 产品类型=PC电脑create view now1asselect 制造商,产品型号,硬盘容量from now,PC电脑where now.产品型号=PC电脑.型号select avg(硬盘容量)平均硬盘容量from now1实验七1)create procedure P1制造商 char(10),产品型号 char(10),产品类型 char(10),速度 int,内存 int,硬盘容量 int,价钱 money asbegin transactiondeclare error1 intinsert into 产品 values(制造商,产品型号,产品类型)set error1=error1+errorinsert into PC电脑 values(产品型号,速度,内存,硬盘容量,价钱)set error1=error1+errorif(error10) beginprint 插入失败,回滚事物rollback transactionendelsebeginprint 成插入成功,提交事物commit transactionendexec P1 制造商=C,产品型号=11100,产品类型=PC电脑,速度=240,内存=32,硬盘容量=2.5,价钱=24992)create procedure P2 as begin transactiondeclare Error2 intinsert into 产品(制造商,产品型号,产品类型)select 制造商,产品型号+1100,便携式电脑from 产品where 产品.产品类型=PC电脑set Error2=Error2+errorinsert into 便携式电脑(型号,速度,内存,硬盘,屏幕大小,价钱)select 型号+1100,速度,内存,硬盘容量,11,价钱+500from PC电脑set Error2=Error2+errorif(Error20)beginprint插入失败,回滚事物rollback transactionendelsebeginprint插入成功,提交事物commit transactionend3)create trigger P3on PC电脑for deleteasdelete from 产品where 产品型号 in (select 型号 from deleted)delete from PC电脑where 硬盘容量50create trigger P4on 产品for updateasdeclare 型号1 char(10)declare 制造商 char(10)select 型号1=产品型号 from insertedselect 制造商=制造商from inserted bwhere b.产品型号=型号1if 制造商 is nullbegin print 错误!rollback transactionendupdate 产品set 制造商=Awhere 制造商=B(4)厂商A收购了B,将所有由B制造的产品改为A制造declare MyCursor cursorDYNAMICfor select 制造商,产品型号,产品类型from 产品where 制造商 = Bfor updateopen MyCursorfetch next from MyCursorupdate 产品set 制造商 = Awhere current of MyCursorwhile(FETCH_STATUS =0)beginfetch next from MyCursorupdate 产品set 制造商 = Awhere current of MyCursorENDdeallocate MyCursorcreate database Moviescreate table 电影明星( 姓名 varchar(20) not null primary key, 地址 varchar(50), 性别 char(2)check(性别=男 or 性别=女), 生日 datetime);create table 制作人与行政总裁( 姓名 varchar(20), 地址 varchar(50), 身份证号 char(18) not null primary key, 资产 int);create table 制片公司( 公司名称 varchar(50) not null primary key, 地址 varchar(50), 行政总裁 char(18)not null references 制作人与行政总裁(身份证号),);create table 电影( 电影名称 varchar(50) not null, 拍摄年份 datetime not null, 长度 int, 是否彩色 char(2)check(是否彩色 = 是 or 是否彩色 = 否), 所属电影公司 varchar(50) references 制片公司(公司名称), 制片人 char(18) referen
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025合作店合同范本xy
- 代办牛羊屠宰合同范本
- 拆除游乐设施合同范本
- 稻米加工合同范本
- 跨境鞋子转让合同范本
- 装修别墅合同范本
- 化粪池清运合同范本
- 个人卡车转让合同范本
- 装修签安全合同范本
- 工程牌匾质保合同范本
- 2025年发展对象考试题库附含答案
- 2025年兵团基层两委正职定向考录公务员试题(附答案)
- 2025年新专长针灸考试题及答案
- 高三生物一轮复习课件微专题5电子传递链化学渗透假说及逆境胁迫
- DBJ50-T-306-2024 建设工程档案编制验收标准
- 2025四川雅安荥经县国润排水有限责任公司招聘5人笔试历年参考题库附带答案详解
- 2025中国银行新疆区分行社会招聘笔试备考试题及答案解析
- 污水采样培训课件
- 药品医疗器械试题及答案
- 子宫内膜类器官构建与临床转化专家共识解读 2
- 幼师培训:如何上好一节课
评论
0/150
提交评论