SQL Server 2008 Express 授予用户权限
将 Windows 用户帐户添加到 SQL Server 2008 数据库的权限的适当 SQL 命令(不通过 GUI)是什么?即..我想授予某人读取权限和另一个人读/写权限..
What is the appropriate SQL commands (not through the GUI) to add a windows user account to permissions on a SQL Server 2008 Database? ie.. I want to give someone read access and another person read/write..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该过程分为两步:
首先,您需要根据该用户的 Windows 凭据为该用户创建一个登录
这将设置甚至连接到 SQL Server 的基本权限
登录后,您可以在每个数据库中创建一个用户,您希望授予该登录权限来执行某些操作:
授予对每个数据库的读取权限数据库中的表,将
db_datareader
角色分配给该用户要授予对数据库中每个表的读取和写入权限,请分配向该用户授予
db_datareader
和db_datawriter
角色,
如果您需要对可以读取或写入哪些表进行更细粒度的控制,您需要手动管理权限,例如通过创建您自己的数据库角色并向这些角色分配权限,然后将您的用户添加到您创建的特定于应用程序的角色
It's a two-step process:
first, you need to create a login for that user, based on its Windows credentials
This sets up the basic permission to even connect to your SQL Server
once you have a login, you can create a user in each database where you want to give that login rights to do something:
to grant read permissions on every table in your database, assign the
db_datareader
role to that userto grant read and write permissions on every table in your database, assign both the
db_datareader
as well as thedb_datawriter
role to that userif you need more fine grained control over what tables can be read from or written to, you need to manage permissions manually, e.g. by creating your own database roles and assigning grants to those roles, and then adding your users to those app-specific roles you created