best way to grant read only access to 2 tables in SQL Server 2005?(在 SQL Server 2005 中授予对 2 个表的只读访问权限的最佳方法?)
问题描述
授予少数用户访问 SQL Server 2005 数据库中几个表的权限的最佳方法是什么?
whats the best way to grant access to a few users to a couple tables in a SQL Server 2005 database?
我知道文献推动了视图的使用,但与授予对实际表的只读访问权限相比有什么好处?
I know the literature pushes the use of views but what is the gain over granting read only access to the actual table?
至少对于表,开销会更少,因为索引和其他限制已经到位并在表中进行管理(单点维护).如果我创建视图,那么我是否不需要维护它们并为它们创建索引......而且这将是 SQL 本身的额外开销?
at least with the table there will be less overhead in that the index and other restraints are already in place and managed at the table (a single point of maintenance). If I make views then won't i need to maintain them and create indexes on them... as well as this will be additional overhead for SQL itself?
推荐答案
CREATE ROLE role_name
GRANT SELECT ON table_name TO role_name
不要忘记将用户添加到该角色.添加个人权限通常是一种不好的做法.
Don't forget to add users to that role. Adding individual permissions is generally a bad practice.
如果您想以不同方式隐藏特定列/名称列/以其他方式过滤数据,则使用视图并授予视图权限非常有用.
Using views and giving permissions to the view is useful if you want to hide particular columns / name columns in different ways / otherwise filter the data.
这篇关于在 SQL Server 2005 中授予对 2 个表的只读访问权限的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 SQL Server 2005 中授予对 2 个表的只读访问权限的
基础教程推荐
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 无法解决整理冲突 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
