第八章 sql试卷答案

举报
资源描述
第八章 sql 答案.doc数据定义和数据操纵题目1、Create?Table?golden?free( 国家代码 ?C(3),金牌数?N(16),银牌数?N(16),铜牌数?N(16))2、CREATE TABLE rate (币种 1 代码 C(2), 币种 2 代码 C(2), 买入价 N(8,4), 卖出价 N(8,4))3、CREATE TABLE 分组情况表 free (组号 C(2),组名 C(10))4、create table course(课程号 c(4) primary key not null,课程名 c(16),学分 n(2) null)5、create table xs(学号 c(8),姓名 c(10),性别 c(2) check 性别$"男女" error "性别必须是男或女" default "女",民族 c(6))6、insert into golden values("001",9,7 ,11)7、alter table 评委表 alter 评委编号 set check left(评委编号,2)=”11”8、( 1) ALTER TABLE 金牌榜 ADD 奖牌总数 I CHECK 奖牌总数>=0(2) UPDATE 金牌榜 SET 奖牌总数=金牌数+银牌数+ 铜牌数9、alter table 教师表 alter 职工号 set check LEFT(职工号,3)="110"10、alter table student add unique 学号 tag 学号11、UPDATE TABB SET 日期 = {^2005.10.01}12、INSERT INTO 分组情况表 VALUES ("01","通俗唱法")13、 ALTER TABLE 学院表 ADD 教师人数 I CHECK 教师人数>=014、 update teacher set 工资=8000 where 姓名="Jack"15、ALTER TABLE 课程表 ADD UNIQUE 课程号 TAG temp16、alter table 教师表 alter column 职工号 set check Left(职工号,2)=”1102”17、解答:update table3 set 等级=“优” where 数学>=60 and 英语>=60 and 信息技术>=60 and (数学+ 英语+信息技术)/3>=90update table3 set 等级=“良” where 数学>=60 and 英语>=60 and 信息技术>=60 and (数学+ 英语+信息技术)/3>=80 and (数学+英语+ 信息技术)/3=60 and 英语>=60 and 信息技术>=60 and (数学+ 英语+信息技术)/3>=70 and (数学+英语+ 信息技术)/3=60 and 英语>=60 and 信息技术>=60 and (数学+ 英语+信息技术)/3>=60 and (数学+英语+信息技术)/3=60 and 英语>=60 and 信息技术>=60)18、update 商品表 set 单价= 出厂单价*0.01 where left(商品号,2)="10"简单查询1. Select * from student into table results where 性别=”男”2、( 1) Select * from 销售表 into table 销售表 2001 where 日期{1980-01-01} order by 出生日期 desc18、Select 订单号,客户号,签订日期,金额 from order into table t107 where 职员号=”107” order by 签订日期 ascSelect 订单号,客户号,签订日期,金额 from order into table t111 where 职员号=”111” order by 签订日期 ascSelect 订单号,客户号,签订日期,金额 from order into table t115 where 职员号=”115” order by 签订日期 asc19、Select * from 教师表 to file one where 工资>4500 order by 职工号 asc简单联接查询1. Select 供应商号,工程号,数量 from 供应,零件 into table supply_temp where 供应.零件号= 零件.零件号and 颜色=” 红” order by 数量 desc2. Select 外币名称,持有数量 from rate_exchange, currency_sl into table rate_temp where rate_exchange.外币代码= currency_sl.外币代码 and 姓名=”林诗因” order by 持有数量 asc3. Select 客户.客户号,身份证,姓名,工作单位,客房.客房号,类型名 ,价格 from 客房,房价,客户,入住 into table tabd where 客房.客房号=入住.客房号 and 房价.类型号=客房.类型号 and 客户.客户号= 入住.客户号 and退房日期>={^2005-04-01} order by 价格 desc4. Select order.订单号,签订日期,商品名,单价,数量 from goods,order,orderitem into table tabletwo where goods.商品号=orderitem. 商品号 and order.订单号=orderitem.订单号 and 客户名=”lilan” order by order.订单号 asc,商品名 asc5. Select 股票简称,现价,买入价,持有数量 from stock_sl,stock_name into table stock_temp where stock_sl.股票代码=stock_name. 股票代码 and 现价>买入价 order by 持有数量 desc6. Select 分类名称,商品名称,进货日期 from 商品,分类 to file infor_a where 商品.分类编码= 分类.分类编码 and year(进货日期 )=40 order by 菜单表.菜编号 desc13. Select * from 评分表 into table two where left(歌手编号,2)=”01” order by 歌手编号 desc,分数 asc14. Select order.订单号,客户名,签订日期 ,商品名,单价,数量 from goods,order,orderitem into table tablethree where goods.商品号=orderitem.商品号 and order.订单号=orderitem.订单号 and 商品号=”a00002” order by order.订单号 asc15. Create view NEW_VIEW as Select student.学号,姓名,系部 from student,score1 where student.学号=score1.学号 and 成绩 is null16、Select 运动员名称,项目名称,名次 from 国家,获奖牌情况 into table 中国 where 国家.国家代码=获奖牌情况.国家代码 and 国家名称=”中国” order by 名次 ascSelect 运动员名称,项目名称,名次 from 国家,获奖牌情况 into table 日本 where 国家.国家代码=获奖牌情况.国家代码 and 国家名称=”日本” order by 名次 ascSelect 运动员名称,项目名称,名次 from 国家,获奖牌情况 into table 美国 where 国家.国家代码=获奖牌情况.国家代码 and 国家名称=”美国” order by 名次 ascSelect 运动员名称,项目名称,名次 from 国家,获奖牌情况 into table 俄罗斯 where 国家.国家代码=获奖牌情况.国家代码 and 国家名称=” 俄罗斯” order by 名次 asc17、Select 职工号,姓名,工资 from 学院表,教师表 into table 计算机 where 学院表.系号=教师表.系号 and 系名=”计算机” order by 职工号 ascSelect 职工号,姓名,工资 from 学院表,教师表 into table 通信 where 学院表.系号=教师表.系号 and 系名=”通信” order by 职工号 ascSelect 职工号,姓名,工资 from 学院表,教师表 into table 信息管理 where 学院表.系号=教师表.系号 and 系名=”信息管理” order by 职工号 asc18、Select 外币名称,持有数量 from currency_sl,rate_exchange into table 林诗因 where currency_sl.外币代码=rate_exchange.外币代码 and 姓名=”林诗因”Select 外币名称,持有数量 from currency_sl,rate_exchange into table 张三丰 where currency_sl.外币代码=rate_exchange.外币代码 and 姓名=”张三丰”Select 外币名称,持有数量 from currency_sl,rate_exchange into table 李寻欢 where currency_sl.外币代码=rate_exchange.外币代码 and 姓名=”李寻欢”19. select 课程名称 from course,score to file new where score.课程编号 =course.课程编号 and 成绩=85 and 英语>=85 and 信息技术>=85 or 数学>=90 and 英语>=90 and 信息技术>=75) order by 学号 desc(5) Create view view1 as;Select xuesheng.学号,姓名,数学,英语,信息技术 from xuesheng,chengji where xuesheng.学号=chengji.学号 and left(xuesheng.学号,8)=”20001001” order by 学号 descSelect * from view1 into table table2分组计算查询1、 Select top 3 employee.职工号 ,姓名,count(*) as 订单数 from employee,orders into table newcoun where employee.职工号=orders. 职工号 group by employee.职工号 order by 订单数 desc 2、Select 政治面目,count(*) as 人数,avg( 年龄) as 平均年龄 from student into table sqlresults group by 政治面目3. Select 课程名,avg( 成绩) as 平均成绩 from score1,course into table NEW_TABLE32 where score1.课程号=course.课程号 group by course.课程号 order by 课程名 asc4.( 1) Select 国家名称,count(*) as 奖牌总数 from 国家,获奖牌情况 into table 假奖牌榜 where 国家.国家代码=获奖牌情况.国
展开阅读全文
温馨提示:
金锄头文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
相关搜索

当前位置:首页 > 办公文档 > 其它办公文档


电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号