77范文网 - 专业文章范例文档资料分享平台

SQL习题(附答案)(8)

来源:网络收集 时间:2019-01-05 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

use library go

alter table 学生

add 民族varchar(6)constraint df_学生_民族default '汉' (2) use library go

alter table 学生

alter column 姓名char(6) go

alter table 学生

add constraint pk_学生_学号primary key (学号) go (3) use library go

alter table 借阅 add 到期日期datetime go (4)

alter table 借阅

add constraint df_借书日期default getdate() for 借书日期

go (5)

alter table 借阅

add constraint fk_借阅_学生foreign key (学号) references 学生(学号) go (7)

alter table 学生drop constraint df_学生_民族 go

alter table 借阅drop constraint df_借书日期 go (8)

create rule phone_rule as

@ph_rl like '0551-2159[0-9][0-9][0-9]' Go (9)

exec sp_bindrule 'phone_rule','出版社.电话' go (10)

exec sp_addtype 编号,'varchar(20)','not null' 习题六 一、选择题

1-5. CCBAB 6-10.CBDBB 11-15.BBBDB 16-20. BCCCA 21-25ADDCC 26-30 CDCBC 二、填空题

1.update 2.where 3.[-] 4.union 5.交叉连接6.into 7.group by 8.revoke 9.order by

10.group by 11.and 12. where 13. 相关子查询14. 交叉连接15. all 16. with rollup 17. distinct

18. from 子句19. 嵌套查询20. truncate table 21.数据转转与转移 三、实践题 1.

select a.姓名,a.出生日期,b.姓名,b.出生日期from 学生a,学生b where a.出生日

期=b.出生日期and a.学号!=b.学号 2.

select 学号,'高考投档成绩',总分from 学生 3.

select distinct(籍贯) from 学生 4.

select avg(总分) from 学生group by 性别 5.

select * from 学生where 籍贯='安徽'

6.

select * from 学生where 性别='女'

and 出生日期=(select max(出生日期) from 学生where 性别='女') go

select * from 学生where 性别='男'

and 出生日期=(select max(出生日期) from 学生where 性别='男') 7.

select* from 学生order by 总分desc 8.

select 学生.学号,姓名,性别,课程号,成绩from 学生,选修 where 学生.学号=选修.学号and 成绩>85 9.

select 姓名,'学生'as 身份from 学生where 性别='男' union

select 姓名,'教师'as 身份from 教师where 性别='男' 10.

select * from 学生where 出生日期between '1990-1-1' and '1991-1-1' 11.

select top 5 * into course from 课程 12.

select 籍贯,count(*) from 学生group by 籍贯 13.

select 学号,姓名,籍贯from 学生where 籍贯='安徽' compute count(籍贯) 14.

select 学号,姓名,籍贯from 学生where 籍贯='安徽' order by left(学号,6) compute count(籍贯) by left(学号,6) 或

select 学号,姓名,籍贯from 学生where 籍贯='安徽' go

select left(学号,6),count(*) from 学生where 籍贯='安徽' group by left(学号,6) 15.

select * from 学生a where 出生日期>=(

select max(出生日期) from 学生b where a.性别=b.性别) 16.

select * from 选修a where 成绩>(

select avg(成绩) from 选修b where a.学号=b.学号) 17.

select * from 选修where 成绩>(select avg(成绩) from 选修) 略 习题七 一、填空题

1.全局变量2.注释语句3.select 语句4.单引号5.表达式6.break 7. 8. max() 9. waitfor 10.end 11. syscomments 12. ‘ab’ 13. 14. T-SQL 15. GO 16. 批

处理

17. Unicode 18. 内嵌表值19. smalldatetime 20. smallmoney 二、选择题

1-5DCDA 6-10DCDBD 11-15 ACBDB 16-20. BDBAB 21-25 DCCBC__

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库SQL习题(附答案)(8)在线全文阅读。

SQL习题(附答案)(8).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/405479.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: