数据库原理与应用课程实验指导书(附答案)(2)

发布时间 : 星期一 文章数据库原理与应用课程实验指导书(附答案)(2)更新完毕开始阅读

二、实验内容和步骤

1、创建Windows NT登录帐户

在SQL Server中添加一个帐户名为“WANG”的Windows NT登录帐户。

2、创建SQL Server登录帐户

在SQL Server中添加一个帐户名为“LIU”,密码为“123456”的SQL Server登录帐户。

3、添加服务器角色成员

将“WANG”这个Windows NT登录帐户添加到系统管理员服务器角色中。

4、添加一个登录帐户为某个数据库的用户

将“LIU” 这个SQL Server登录帐户添加为CPXS数据库中一个用户,名称也为“LIU”。

5、添加数据库角色

在CPXS数据库中添加一个名为“ROLE”的角色。

6、添加数据库角色成员

将CPXS数据库中名为“LIU”这个用户添加为“ROLE”角色成员。

7、用户、角色的授权

授予“LIU”用户和“ROLE”角色对CPXSB表的查询权限和数量列的修改权限。

8、收回用户、角色的

收回“LIU”用户的所有权限。并查看是否能打开CPXSB表。

9、拒绝用户、角色的权限

重新授予“LIU”用户对CPXSB表的查询权限和数量列的修改权限。再拒绝该用户的所有权限。并查看是否能打开CPXSB表,并通过此实例阐述收回权限与拒绝权限的区别。

实验3:

create database CPXS on

(name='CPXS_data',

filename='D:\\dbf\\CPXS_data.mdf', size=5,

maxsize=50, filegrowth=10% )

log on

(name='CPXS_log',

filename='D:\\dbf\\CPXS_log.mdf', size=2,

maxsize=10, filegrowth=2 )

alter database CPXS

modify file (name='CPXS_data',filegrowth=5)

create table CP (

产品编号 char(6) primary key, 产品名称 char(30) not null, 价格 float(8), 库存量 int )

create table XSS (

客户编号 char(6) primary key, 客户名称 char(30) not null, 地区 char(10),

负责人 char(8), 电话 char(12) )

create table CPXSB (

产品编号 char(6) foreign key references CP(产品编号), 客户编号 char(6) foreign key references XSS(客户编号), 销售日期 datetime, 数量 int not null,

销售额 float(4) not null,

constraint PK_CPXSB primary key(产品编号,客户编号,销售日期) )

insert into CP

values('200001','柜式空调',3000,200)

insert into CP

values('200002','微波炉',1000,100,NULL)

insert into CP

values('200003','抽油烟机',1200,50,NULL)

alter table CP

add 产品简列 varchar(50)

update CP

set 价格=价格*0.8

delete from CP

where 价格*0.9<1500

实验四: 1.

select 产品编号,产品名称,价格 from CP

select 客户编号 as 'Customer id' ,客户名称 as 'Customer name' from XSS

where 地区='南京'

select 产品编号,产品名称,评价= case

when 价格<1000 then '廉价产品'

when 价格>=1000 and 价格<2000 then '一般产品' when 价格>=2000 and 价格<3000 then '昂贵产品' else '很昂贵产品' end from CP

select 产品编号,产品名称,产品总值=价格*库存量 from CP

select 客户编号 from CPXSB

group by 客户编号

having count(产品编号)>=1

select * from CP

where 价格>1000 and 价格<2000

select * from CP

where 产品名称 like '冰箱_A' 2.

select 总价格=sum(价格) from CP

select 产品编号 ,sum(销售额) 销售额 from CPXSB

where 销售日期='2004-3-18' group by 产品编号

select 客户编号 from CPXSB

group by 客户编号

having count(产品编号)>=2

实验五

联系合同范文客服:xxxxx#qq.com(#替换为@)