SQL Server:你能限制对一张表的访问吗

编程入门 行业动态 更新时间:2024-10-20 05:20:03
本文介绍了SQL Server:你能限制对一张表的访问吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我认为答案是否定的,但我希望让某人访问 SQL Server 数据库,但我真的只希望他们能够访问一个表.

I think the answer is no but I'm looking to give someone access to a SQL Server database but I only really want them to have access to one table.

限制某人只能访问一个数据库很容易,但不知道我是否可以限制为单个表.

It's easy enough to limit someone to only access one database but have no idea if I can limit to a single table.

我的想法是用另一个表的同义词创建另一个数据库,然后限制对该数据库的访问,但我想知道是否有人能想到更好的方法.

My thoughts were to create another database with a synonym to the other table and then limit the access to that database but I wondered if someone could think of a better way.

我也不相信它会起作用,因为我认为会有权限冲突.

I'm also not convinced that it will work as I think there will be a conflict of permissions.

推荐答案

是.

exec sp_msforeachtable "DENY SELECT ON ? TO [username];" GO GRANT SELECT ON [schemaName].[tableName] to [username] Go

虽然可行,但您最好使用角色 和 AD 组.

While that works, you would probably be better off managing permissions using roles and AD groups.

更多推荐

SQL Server:你能限制对一张表的访问吗

本文发布于:2023-11-22 06:42:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616364.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:你能   SQL   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!