文档详情

西北工业大学数据库实验报告.doc

发布:2018-10-20约3.59千字共11页下载文档
文本预览下载声明
WORD文档下载可编辑 专业技术资料分享 《数据库原理》实验报告 题目:实验三:数据完整性与安全性控制 学号 姓名 班级 日期 2014302692 孟玉军16.10.18 实验内容、步骤以及结果 利用图形用户界面对实验一中所创建的Student库的S表中,增加以下的约束和索引。(18分,每小题3分) 非空约束:为出生日期添加非空约束。 主键约束:将学号(sno)设置为主键,主键名为pk_sno。 唯一约束:为姓名(sname)添加唯一约束(唯一键),约束名为uk_sname。 缺省约束:为性别(ssex)添加默认值,其值为“男”。 CHECK约束:为SC表的成绩(grade)添加CHECK约束,约束名为ck_grade,其检查条件为:成绩应该在0-100之间。 外键约束:为SC表添加外键约束,将sno,cno设置为外键,其引用表分别是S表和C表,外键名称分别为fk_sno,fk_cno。 在图形用户界面中删除以上小题中已经创建的各种约束,用SQL语言分别重新创建第1题中的(2)-(6)小题.(15分,每小题3分,提示:alter table add constraint) (2) alter table S add constraint pk_sno primary key(sno) (3) alter table S add constraint uk_sname unique(sname) (4) alter table S add constraint uk_sex default(男) for ssex (5) alter table SC add constraint ck_grade check(grade between 0 and 100) (6) alter table SC add constraint fk_sno foreign key(sno) references S(sno) alter table SC add constraint fk_cno foreign key(cno) references C(cno) 利用图形用户界面根据上述SC表中的外键定义画出由S,C,SC表构成的数据库关系图。(5分,提示:选中student - 数据关系图) 用SQL语言删除S表中所创建的缺省约束和外键约束。(6分,每小题3分) alter table S drop constraint uk_sname alter table SC drop constraint fk_sno 在图形用户界面中创建新登录名以及用户。(16分) 根据第五版教材第四章 第7题,创建数据库company和其中的基本表,并创建该题中所需要用到的各个用户以及相关的登录名。(10分) 用图形用户界面完成以下的权限赋予:(每小题3分) 用户王明对两个表均有Select和Insert的权力。 用户李勇对职工表具有Select权力,对工资字段具有更新权力。 用SQL语句授权和收回权限并对权限加以验证。(40分,每题20分) 根据第五版教材第四章 第7题。 1). grant select on employee,department TO 王明 2). grant insert ,delete on employee to 李勇 grant insert ,delete on department to 李勇 3).先创建视图; create view view_i as select * from employee where ename=CURRENT_USER 再进行授权: grant select on view_i to public 4). grant select,update(salary) on employee to 刘星 5). grant alter on employee to 张新 grant alter on department to 张新 6). grant all privileges on department to 周平 with grant option grant all privileges on employee to 周平 with grant option 7).创建部门工资视图; create view department_salary(department_dname,max_salary,min_salary,avg_salary) as select dname,max(
显示全部
相似文档