当前位置:网站首页>实验1.SQL Server的安全机制
实验1.SQL Server的安全机制
2022-07-15 11:06:00 【一只野指针.】
**目录:
1.实验目的
2.实验内容
3.回答问题
**
sql代码
https://download.csdn.net/download/weixin_50836014/85970089
1.实验目的
通过本实验,掌握SQL Server安全机制,包括SQL Server安全、数据库用户与权限,掌握身份验证、登录、数据库用户、服务器角色、数据库角色、权限与授权方法等相关概念及其相互关系。
2.实验内容
(1) 创建一个数据库。在新创建的数据库下创建一个学生基本信息表,插入若干记录。
create database test1
use test1
create table stu(
姓名 varchar(20),
学号 varchar(10),
性别 varchar(5))
insert into stu ( 姓名,学号,性别)
values ('张三','1110191111','男'),
('李四','1110191259','女'),
('王五','1110191389','男'),
('孙六','1110192596','女');
(2) 创建一个Windows身份验证的登录1,将默认数据库设置为Master数据库。将登录1设置为数据库系统管理员。

--登录1授权
USE [master]
GO
CREATE LOGIN [DESKTOP-IL88V2D\test1] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
ALTER SERVER ROLE [sysadmin] ADD MEMBER [DESKTOP-IL88V2D\test1]
GO
查看登录1的配置:

(3) 创建一个Windows身份验证的登录2,将默认数据库设置为新创建的数据库。授权登录2为新创建的数据库的管理员。
--登录2授权
USE [test1]
GO
CREATE LOGIN [DESKTOP-IL88V2D\test2] FROM WINDOWS WITH DEFAULT_DATABASE=[test1]
GO
ALTER USER [DESKTOP-IL88V2D\test2] WITH DEFAULT_SCHEMA=[dbo]
GO
ALTER ROLE [db_owner] ADD MEMBER [DESKTOP-IL88V2D\test2]
GO
检查登录2的权限:

(4) 撤消登录2的新创建的数据库的管理员权限。
--登录2收权
GO
ALTER ROLE [db_owner] Drop MEMBER [DESKTOP-IL88V2D\test2]
GO

(5) 授权登录2查询和更新学生基本信息表中部分字段的权限。验证查询、有权限更新、无权限更新、无权限插入和删除。
--登录2的再次授权
use [test1]
GO
GRANT SELECT ON stu TO [DESKTOP-IL88V2D\test2]
GO
GRANT UPDATE (学号) ON stu TO [DESKTOP-IL88V2D\test2]
GO
登录2的验证:


有select权限:
有更新权限:
无更新权限:
无权插入:
无权删除:
3.回答下列问题
(1) 简述什么是默认数据库并用实验结果说明不同的默认数据库在登录到数据库服务器后有什么不同。
默认数据库就以用户名登录后默认可以使用的数据库,用户有一定的权限能对默认数据库进行操作。由于用户权限的不同,可操作的数据库也不同,如上面的登录2,其只能对默认数据库操作,无权操作其他数据库。
(2) 说明实验内容(2)、(3)、(5)中所用的授权方法的差异,简述每种方法的优缺点。
(2)中的授权是将登录1作为整个数据库服务器的管理员,登录1可以获得所有数据库的全部权限,有安全隐患。
(3)中的授权使登录2获取了某一个特定数据库的全部的操作权限,但不能对其它数据库进行操作,安全性更高。
(5)中的授权只授予登录2对一个数据库中的部分操作权限,安全性优于(2)和(3)。
4.SQL代码
边栏推荐
- What are the problems we need to pay attention to in setting the standard of Baidu search basic information?
- 软件测试W模型
- Analysis of key technologies of Pan cloud desktop
- Issue 41: a project is failing
- C WinForm form form basic properties
- Analysis of problems related to C language pointer
- 工程监测振弦传感器无线采集仪外接数字传感器
- 【C】 Creation and destruction of function stack frames
- 送你的代碼上太空,與華為雲一起開發“最偉大的作品”
- Issue 42: the so-called management team
猜你喜欢

快速傅里叶变换

从底层结构开始学习FPGA----MMCM与PLL

Xu Shiwei: la voie de l'évolution de go +.

Deep understanding and recognition of C language symbols

What are the problems we need to pay attention to in setting the standard of Baidu search basic information?

【C】 Practical debugging skills
![[C exercise] print diamond](/img/fb/3d60abbadbed41b51e76cf397407e8.png)
[C exercise] print diamond

软件测试W模型

Analysis of problems related to C language pointer

High weight website has not been filed. Is it normal to reduce the weight in batches?
随机推荐
Compare the high-quality [test report] template with your own?
Apt get cannot use syntax error
Version announcement | Apache Doris 1.1 release version officially released!
Analyse de la « collaboration » du Bureau collaboratif pourquoi, le Bureau numérique et comment facile « résoudre le problème »?
卷到自己?继 Imagen 之后,推出200 亿文本生成的图像模型惊呆网友!
Find string length
Data transmission: Practice of batch extraction of isomorphic and heterogeneous IP data sources
[practice C] xiaolele walks up the steps
Issue 37: mapstate analysis
高权重没备案网站,批量降权,正常吗?
保持电气化时代的交通安全“零伤亡”,沃尔沃底气何来?
Inner class
Container interview questions
Which is more suitable to be an advanced anti DDoS server, cloud server or physical machine
Codeforces Round #736 (Div. 2) (A-D)
第五十三期:彻底理解MVC,MVP和MVVM
What is the difference between VDD, VCC, VSS, GND and ground?
30万奖池等你来战!自然语言处理(NLP)赛事合集来啦
[C exercise] inverted string
Analyze the meaning of "collaboration" in collaborative office, and how can digital office easily "solve the problem"?