問題描述
授予少數用戶訪問 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 個表的只讀訪問權限的最佳方法?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!