GRANT 类型权限 (Transact-SQL)GRANT Type Permissions (Transact-SQL)

适用对象:是SQL Server 是Azure SQL 数据库 否Azure Synapse Analytics (SQL DW) 否并行数据仓库APPLIES TO: yesSQL Server yesAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

授予对类型的权限。Grants permissions on a type.

“主题链接”图标 Transact-SQL 语法约定Topic link icon Transact-SQL Syntax Conventions

语法Syntax

  
GRANT permission  [ ,...n ] ON TYPE :: [ schema_name . ] type_name  
    TO <database_principal> [ ,...n ]  
    [ WITH GRANT OPTION ]  
    [ AS <database_principal> ]  
  
<database_principal> ::=   
        Database_user   
    | Database_role   
        | Application_role   
    | Database_user_mapped_to_Windows_User   
    | Database_user_mapped_to_Windows_Group   
    | Database_user_mapped_to_certificate   
    | Database_user_mapped_to_asymmetric_key   
    | Database_user_with_no_login  

参数Arguments

permission permission
指定可以授予的类型权限。Specifies a permission that can be granted on a type. 有关权限的列表,请参阅本主题后面的“备注”部分。For a list of the permissions, see the Remarks section later in this topic.

ON TYPE :: [ schema_name. ON TYPE :: [ schema_name. ] type_name ] type_name
指定要授予其权限的类型。Specifies the type on which the permission is being granted. 需要使用作用域限定符 (::) 。The scope qualifier (::) is required. 如果未指定 schema_name,则使用默认架构 。If schema_name is not specified, the default schema will be used. 如果指定了 schema_name,则需要使用架构作用域限定符 (.) 。If schema_name is specified, the schema scope qualifier (.) is required.

TO <database_principal> 指定要向其授予权限的主体。TO <database_principal> Specifies the principal to which the permission is being granted.

WITH GRANT OPTIONWITH GRANT OPTION
指示该主体还可以向其他主体授予所指定的权限。Indicates that the principal will also be given the ability to grant the specified permission to other principals.

AS <database_principal> 指定一个主体,执行该查询的主体从该主体获得授予该权限的权利。AS <database_principal> Specifies a principal from which the principal executing this query derives its right to grant the permission.

Database_user Database_user
指定数据库用户。Specifies a database user.

Database_role Database_role
指定数据库角色。Specifies a database role.

Application_role Application_role
适用于SQL Server 2008SQL Server 2008 及更高版本、SQL 数据库SQL DatabaseApplies to: SQL Server 2008SQL Server 2008 and later, SQL 数据库SQL Database

指定应用程序角色。Specifies an application role.

Database_user_mapped_to_Windows_User Database_user_mapped_to_Windows_User
适用于SQL Server 2008SQL Server 2008 及更高版本Applies to: SQL Server 2008SQL Server 2008 and later

指定映射到 Windows 用户的数据库用户。Specifies a database user mapped to a Windows user.

Database_user_mapped_to_Windows_Group Database_user_mapped_to_Windows_Group
适用于SQL Server 2008SQL Server 2008 及更高版本Applies to: SQL Server 2008SQL Server 2008 and later

指定映射到 Windows 组的数据库用户。Specifies a database user mapped to a Windows group.

Database_user_mapped_to_certificate Database_user_mapped_to_certificate
适用于SQL Server 2008SQL Server 2008 及更高版本Applies to: SQL Server 2008SQL Server 2008 and later

指定映射到证书的数据库用户。Specifies a database user mapped to a certificate.

Database_user_mapped_to_asymmetric_key Database_user_mapped_to_asymmetric_key
适用于SQL Server 2008SQL Server 2008 及更高版本Applies to: SQL Server 2008SQL Server 2008 and later

指定映射到非对称密钥的数据库用户。Specifies a database user mapped to an asymmetric key.

Database_user_with_no_login Database_user_with_no_login
指定无相应服务器级主体的数据库用户。Specifies a database user with no corresponding server-level principal.

RemarksRemarks

类型是架构级的安全对象,包含于权限层次结构中作为其父级的架构中。A type is a schema-level securable contained by the schema that is its parent in the permissions hierarchy.

重要

GRANT、DENY 和 REVOKE 权限不适用于系统类型 。GRANT, DENY, and REVOKE permissions do not apply to system types. 可以为用户定义类型授予权限。User-defined types can be granted permissions. 有关用户定义类型的详细信息,请参阅使用 SQL Server 中的用户定义类型For more information about user-defined types, see Working with User-Defined Types in SQL Server.

下表列出了可授予的对类型最为具体的限定权限,以及隐含这些权限的更为通用的权限。The most specific and limited permissions that can be granted on a type are listed in the following table, together with the more general permissions that include them by implication.

类型权限Type permission 类型权限隐含的权限Implied by type permission 架构权限隐含的权限Implied by schema permission
CONTROLCONTROL CONTROLCONTROL CONTROLCONTROL
在运行 CREATE 语句前执行EXECUTE CONTROLCONTROL 在运行 CREATE 语句前执行EXECUTE
REFERENCESREFERENCES CONTROLCONTROL REFERENCESREFERENCES
TAKE OWNERSHIPTAKE OWNERSHIP CONTROLCONTROL CONTROLCONTROL
VIEW DEFINITIONVIEW DEFINITION CONTROLCONTROL VIEW DEFINITIONVIEW DEFINITION

权限Permissions

授权者(或用 AS 选项指定的主体)必须具有带 GRANT OPTION 的相同权限,或具有隐含所授予权限的更高权限。The grantor (or the principal specified with the AS option) must have either the permission itself with GRANT OPTION, or a higher permission that implies the permission being granted.

若要使用 AS 选项,还必须满足以下附加要求:If you are using the AS option, the following additional requirements apply.

ASAS 所需的其他权限Additional permission required
数据库用户Database user 对用户的 IMPERSONATE 权限、db_securityadmin 固定数据库角色的成员身份、db_owner 固定数据库角色的成员身份或 sysadmin 固定服务器角色的成员身份 。IMPERSONATE permission on the user, membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
映射到 Windows 登录名的数据库用户Database user mapped to a Windows login 对用户的 IMPERSONATE 权限、db_securityadmin 固定数据库角色的成员身份、db_owner 固定数据库角色的成员身份或 sysadmin 固定服务器角色的成员身份 。IMPERSONATE permission on the user, membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
映射到 Windows 组的数据库用户Database user mapped to a Windows group Windows 组的成员身份、db_securityadmin 固定数据库角色的成员身份、db_owner 固定数据库角色的成员身份或 sysadmin 固定服务器角色的成员身份 。Membership in the Windows group, membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
映射到证书的数据库用户Database user mapped to a certificate db_securityadmin 固定数据库角色的成员身份、db_owner 固定数据库角色的成员身份或 sysadmin 固定服务器角色的成员身份 。Membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
映射到非对称密钥的数据库用户Database user mapped to an asymmetric key db_securityadmin 固定数据库角色的成员身份、db_owner 固定数据库角色的成员身份或 sysadmin 固定服务器角色的成员身份 。Membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
未映射到任何服务器主体的数据库用户Database user not mapped to any server principal 对用户的 IMPERSONATE 权限、db_securityadmin 固定数据库角色的成员身份、db_owner 固定数据库角色的成员身份或 sysadmin 固定服务器角色的成员身份 。IMPERSONATE permission on the user, membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
数据库角色Database role 对角色的 ALTER 权限、db_securityadmin 固定数据库角色的成员身份、db_owner 固定数据库角色的成员身份或 sysadmin 固定服务器角色的成员身份 。ALTER permission on the role, membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
应用程序角色Application role 对角色的 ALTER 权限、db_securityadmin 固定数据库角色的成员身份、db_owner 固定数据库角色的成员身份或 sysadmin 固定服务器角色的成员身份 。ALTER permission on the role, membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.

示例Examples

以下示例使用 VIEW DEFINITION 授予用户 GRANT OPTION 对用户定义类型 PhoneNumberKhalidR 权限。The following example grants VIEW DEFINITION permission with GRANT OPTION on the user-defined type PhoneNumber to user KhalidR. PhoneNumber 位于架构 Telemarketing 中。PhoneNumber is located in the schema Telemarketing.

GRANT VIEW DEFINITION ON TYPE::Telemarketing.PhoneNumber   
    TO KhalidR WITH GRANT OPTION;  
GO  

另请参阅See Also

DENY 类型权限 (Transact-SQL) DENY Type Permissions (Transact-SQL)
REVOKE 类型权限 (Transact-SQL) REVOKE Type Permissions (Transact-SQL)
CREATE TYPE (Transact-SQL) CREATE TYPE (Transact-SQL)
权限(数据库引擎) Permissions (Database Engine)
安全对象 Securables
主体(数据库引擎)Principals (Database Engine)