开发者

Control access to certain columns of table?

开发者 https://www.devze.com 2023-04-04 06:52 出处:网络
Is it possible to control access to certain column of table an开发者_开发技巧d allow access to only particular column in MS-SQL server? If yes how? IF no Is there any alternative? IMO the correct way

Is it possible to control access to certain column of table an开发者_开发技巧d allow access to only particular column in MS-SQL server? If yes how? IF no Is there any alternative?


IMO the correct way to do this is to use views and secure the view to the people who can access it.

See here on Ode To Code for a better example.

say you have a table (the_table) with three cols (a, b & c) you can create a view that has only the cols your require

create view show_colc_view 
as 
  select c from  the_table

You can then secure the people who have CRUD privilege on the both the table and view.

so the people concerned can do this:

select * from  show_colc_view

but not

select * from  the_table


SQL Server does in fact support column level permissions.

See this article for details of how to apply them via the SSMS UI.


Create a view with the allowed columns, and grant the user access to the view only..

table columns: a, b, c, d, e, f

CREATE VIEW allowed as SELECT a,b,c FROM table;
GRANT SELECT ON allowed to <user>;

then the user should query the view and not the table:

SELECT * from allowed;

and they'll only see columns a, b and c (not d, e or f)

0

精彩评论

暂无评论...
验证码 换一张
取 消