Slackware中文帮助文档(前言)
2009-05-29 18:13
651 查看
对数据库jwgl,按要求建立以下视图
1、查询班级女学生的学生编号、学生姓名、性别 及学生所属班级名称,并把此查询生成视图。
源代码:use jwgl
go
create view girltab as
select student_id,student_name,sex,class_id from student where sex=0
select * from girltab
2、修改上题所建视图定义,除显示班级女学生编号、学生姓名、性别、及学生所属班级名称外,还要求显示学生年龄。
源代码:alter view girltab as
select student_id,student_name,sex,class_id,age from student where sex=0
3、查询上题生成的视图。
源代码:select * from girltab
4、在生成的视图中插入一名男学生的记录。
源代码:insert into girltab values ('g940302','去翻',1,'g9903',20)
select * from student
5、在视图的定义上加上子句with check option,再通过视图插入一名男学生的记录,能否成功,想想为什么。
(1)、没加 with check option ―可以插入记录成功
源代码:alter view girltab as
select student_id,student_name,sex,class_id,age from student where sex=0
insert into girltab values ('g940303','丁琪',1,'g9903',20)
select * from student
(2)、加了 with check option ―插入记录失败
源代码:alter view girltab as
select student_id,student_name,sex,class_id,age from student where sex=0
with check option
insert into girltab values ('g940304','丁',1,'g9903',20)
不能成功,因为with check option子句会检查修改是否满足视图定义。视图定义的是女同学,插入男生记录不满足女同学条件,所以不能插入成功。
1、查询班级女学生的学生编号、学生姓名、性别 及学生所属班级名称,并把此查询生成视图。
源代码:use jwgl
go
create view girltab as
select student_id,student_name,sex,class_id from student where sex=0
select * from girltab
2、修改上题所建视图定义,除显示班级女学生编号、学生姓名、性别、及学生所属班级名称外,还要求显示学生年龄。
源代码:alter view girltab as
select student_id,student_name,sex,class_id,age from student where sex=0
3、查询上题生成的视图。
源代码:select * from girltab
4、在生成的视图中插入一名男学生的记录。
源代码:insert into girltab values ('g940302','去翻',1,'g9903',20)
select * from student
5、在视图的定义上加上子句with check option,再通过视图插入一名男学生的记录,能否成功,想想为什么。
(1)、没加 with check option ―可以插入记录成功
源代码:alter view girltab as
select student_id,student_name,sex,class_id,age from student where sex=0
insert into girltab values ('g940303','丁琪',1,'g9903',20)
select * from student
(2)、加了 with check option ―插入记录失败
源代码:alter view girltab as
select student_id,student_name,sex,class_id,age from student where sex=0
with check option
insert into girltab values ('g940304','丁',1,'g9903',20)
不能成功,因为with check option子句会检查修改是否满足视图定义。视图定义的是女同学,插入男生记录不满足女同学条件,所以不能插入成功。
相关文章推荐
- Slackware中文帮助文档(第二章 帮助)
- Slackware中文帮助文档(第一章 Slackware Linux简介)
- VIM7.3添加中文帮助文档
- jspsmartupload中文帮助文档
- Flex中文帮助文档下载地址
- 【Scikit-Learn 中文文档】寻求帮助 - 关于科学数据处理的统计学习教程 - scikit-learn 教程 | ApacheCN
- 【Scikit-Learn 中文文档】四十九:寻求帮助 - 关于科学数据处理的统计学习教程 - scikit-learn 教程 | ApacheCN
- 【Scikit-Learn 中文文档】寻求帮助 - 关于科学数据处理的统计学习教程 - scikit-learn 教程 | ApacheCN
- 让vim使用中文帮助文档
- git中文帮助文档
- 强大的矢量图形库:Raphael JS 中文帮助文档及教程
- highcharts中文帮助文档
- Flex中文帮助文档+Flex组件及样式浏览器+Flex滤镜浏览器+chartSample浏览器+easing浏览器
- 02_Eclipse中设置javadoc中文帮助文档
- 安装VIM中文帮助文档
- 适合中大型网站的广告统计系统OpenADS实战手册+中文帮助文档
- Prototype1.4 中文帮助文档
- jQuery全屏滚动插件FullPage.js中文帮助文档API
- 如何让 eclipse 全面 使用 Java API中文帮助文档
- vim中文帮助文档安装