I want to provide only READ access to a single table in SQL Server Database for a given user - xyz
我想只为给定用户 - xyz提供SQL Server数据库中单个表的READ访问权限
Have gone through these questions:
经历过以下问题:
How do I grant read access for a user to a database in SQL Server?
如何为SQL Server中的数据库授予用户读取权限?
Granting a SQL Server Login Access to a Database - SQL Server
授予对数据库的SQL Server登录访问权限 - SQL Server
best way to grant read only access to 2 tables in SQL Server 2005?
在SQL Server 2005中授予对2个表的只读访问权限的最佳方法?
But it raises some fundamental questions for me, what is the difference in giving the access through role and user name?
但它为我提出了一些基本问题,通过角色和用户名提供访问权限有何不同?
Kindly provide a efficient way to do this
请提供一种有效的方法来做到这一点
2 个解决方案
#1
27
I have gotten around this problem in this manner:
我以这种方式解决了这个问题:
CREATE LOGIN XYZ
WITH PASSWORD = 'PASSWORD'
After the login for XYZ is created, then create a user for the above login created
创建XYZ登录后,创建用户以创建上述登录
CREATE USER xyz FOR LOGIN xyz
Then grant the select, update permission, in my case it is just select on a particular table
然后授予select,update权限,在我的情况下,它只是在特定表上选择
GRANT SELECT ON DBNAME.TABLE_NAME TO USERNAME
The sources I have referred for this are
我提到的来源是
-
http://technet.microsoft.com/en-us/library/aa337545.aspx (refer the bottom code part titled create a database user)
http://technet.microsoft.com/en-us/library/aa337545.aspx(参考标题为创建数据库用户的底部代码部分)
-
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/959f9307-0494-4883-9d17-fad684705864/grant-select-permission-on-a-table?forum=sqldatabaseengine
#2
2
Granting access through user name is specific only for that user.
通过用户名授予访问权限仅适用于该用户。
But granting access through role is applicable to all the users who belong to that role. Role is used for assigning permissions to a group of users.
但是,通过角色授予访问权限适用于属于该角色的所有用户。角色用于为一组用户分配权限。
#1
27
I have gotten around this problem in this manner:
我以这种方式解决了这个问题:
CREATE LOGIN XYZ
WITH PASSWORD = 'PASSWORD'
After the login for XYZ is created, then create a user for the above login created
创建XYZ登录后,创建用户以创建上述登录
CREATE USER xyz FOR LOGIN xyz
Then grant the select, update permission, in my case it is just select on a particular table
然后授予select,update权限,在我的情况下,它只是在特定表上选择
GRANT SELECT ON DBNAME.TABLE_NAME TO USERNAME
The sources I have referred for this are
我提到的来源是
-
http://technet.microsoft.com/en-us/library/aa337545.aspx (refer the bottom code part titled create a database user)
http://technet.microsoft.com/en-us/library/aa337545.aspx(参考标题为创建数据库用户的底部代码部分)
-
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/959f9307-0494-4883-9d17-fad684705864/grant-select-permission-on-a-table?forum=sqldatabaseengine
#2
2
Granting access through user name is specific only for that user.
通过用户名授予访问权限仅适用于该用户。
But granting access through role is applicable to all the users who belong to that role. Role is used for assigning permissions to a group of users.
但是,通过角色授予访问权限适用于属于该角色的所有用户。角色用于为一组用户分配权限。