TSQL 授予对所有表的读写权限

2021-09-10 00:00:00 tsql sql-server

正在设置

EXEC sp_addrolemember N'db_datareader', N'User'
EXEC sp_addrolemember N'db_datawriter', N'User'

与将所有表上的 SELECT/INSERT/DELETE/UPDATE 授予用户相同

Is the same as granting SELECT/INSERT/DELETE/UPDATE on all tables to User

GRANT SELECT ON  [Schema].[Table] TO [User]
GRANT INSERT ON  [Schema].[Table] TO [User]
GRANT DELETE ON  [Schema].[Table] TO [User]
GRANT UPDATE ON  [Schema].[Table] TO [User]

推荐答案

来自 MSDN (db_datawriter、db_datareader):

From MSDN (db_datawriter, db_datareader) :

db_datawriter 固定数据库角色的成员可以添加、删除或更改所有用户表中的数据.

Members of the db_datawriter fixed database role can add, delete, or change data in all user tables.

db_datareader 固定数据库角色的成员可以对数据库中的任何表或视图运行 SELECT 语句.

Members of the db_datareader fixed database role can run a SELECT statement against any table or view in the database.

所以,效果是一样的,只是在第一种情况下更容易管理.

So, the effect is the same, only easier to administer in the first case.

相关文章