Ms Sql Server 简明教程

MS SQL Server - Assign Permissions

Permissions 参照涉及主体对可保护对象的访问级别规则。用户可以在 MS SQL Server 中授予、撤销和拒绝权限。

Permissions refer to the rules governing the levels of access that principals have to securables. You can grant, revoke and deny permissions in MS SQL Server.

若要分配权限,可使用以下两个方法之一。

To assign permissions either of the following two methods can be used.

Method 1 – Using T-SQL

Syntax

Use <database name>
Grant <permission name> on <object name> to <username\principle>

Example

要在“TestDB”数据库中向用户“TestUser”分配对名为“TestTable”的对象进行选择操作的权限,请运行以下查询。

To assign select permission to a user called 'TestUser' on object called 'TestTable' in 'TestDB' database, run the following query.

USE TestDB
GO
Grant select on TestTable to TestUser

Method 2 – Using SSMS (SQL Server Management Studio)

Step 1 - 连接到实例,然后展开文件夹,如下方的快照所示。

Step 1 − Connect to instance and expand folders as shown in the following snapshot.

assign permissions

Step 2 - 右键点击 TestUser,然后点击属性。将会看到以下画面。

Step 2 − Right-click on TestUser and click Properties. The following screen appears.

database testuser

Step 3 点击搜索,并选择具体选项。点击对象类型,选择表格,然后点击浏览。选择“TestTable”,然后点击确定。将会看到以下画面。

Step 3 Click Search and select specific options. Click Object types, select tables and click browse. Select 'TestTable' and click OK. The following screen appears.

database testuser2

Step 4 如上方的快照所示,选择选择权限下授予列的复选框,然后点击确定。

Step 4 Select checkbox for Grant column under Select permission and click OK as shown in the above snapshot.

database testuser3

Step 5 选择授予“TestUser”对“TestDB”数据库中的“TestTable”的权限。点击确定。

Step 5 Select permission on 'TestTable' of TestDB database granted to 'TestUser'. Click OK.