SQL Server - 基于每个表的权限?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5623519/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 10:06:39  来源:igfitidea点击:

SQL Server - Permission on a per table basis?

sqlsql-server

提问by John

I have a .net where I only have read access to the SQL Server database. Is it possible for SQL Server to give me write access to just ONE of the tables in the database, and restrict me to read only for the rest of the database?

我有一个 .net,我只能在其中读取 SQL Server 数据库。SQL Server 是否可以让我只对数据库中的一个表进行写访问,并限制我对数据库的其余部分进行只读访问?

回答by p.campbell

Use this TSQL script, if you need:

如果需要,请使用此 TSQL 脚本:

EXEC sp_addrolemember N'db_datareader', N'User1';

GRANT INSERT, UPDATE, SELECT ON 
   MyTable 
TO User1 --for multiples, it's   TO User1,User2

回答by Daren

In SQL Server Management Studio, right-click the read-only user in database name|security|Users and select Properties.

在 SQL Server Management Studio 中,右键单击数据库名称|security|Users 中的只读用户,然后选择“属性”。

Select "Securables" and click "Search...". In the popup select "All objects of the type..." and click OK. Select "Tables" in the next window and click OK.

选择“Securables”并单击“搜索...”。在弹出窗口中选择“所有类型的对象...”,然后单击“确定”。在下一个窗口中选择“表”,然后单击“确定”。

Then back in the Securables window, for each table that the user may write to: Click on the table, and in the Permissions window underneath, in the "Grant" column, select "Insert", "Select" and "Update".

然后回到 Securables 窗口,对于用户可能写入的每个表: 单击该表,然后在下方的“权限”窗口中的“授予”列中,选择“插入”、“选择”和“更新”。

回答by RQDQ

Yes, yes it is.

是的,是的。

Just grant yourself the ReadOnly role and give yourself explicit write permissions to the table in question.

只需授予自己 ReadOnly 角色并授予自己对相关表的明确写入权限。