使用联系人

Contacts are schema-level objects that contain details about which user or group of users can be contacted for a specific purpose. For example, one contact named data_stewards might include an email distribution list while another named support_department might include the URL of the department's website.

Contacts can be associated with other objects such as databases and tables so the right person can be contacted for assistance with those objects. For example, there might be a contact on a table that contains the users who can help gain access to the table. The purpose of the contact is not a property of the contact, but rather the association between a contact and a specific object. For example, the same contact might provide general support for one table while providing access approval for another.

一个对象可以有多个联系人,只要每个联系人的目的对该对象来说是唯一的。例如,一个表格可能有一个联系人授予对该表的访问权限,另一个联系人为该表格提供一般支持。当用户查看与对象关联的联系人时,他们会看到每个联系人的目的以及通信方式,因此他们知道出于特定原因与谁通信以及如何联系他们。

Data users see these contacts when they are using the Database Explorer in Snowsight to navigate their databases, schemas, and table-like objects. Snowflake features that send notifications to users can use the contact associated with an object to communicate with the users.

继承和覆盖联系人

联系人由后代对象继承。如果将某个联系人关联到一个作为父对象的对象上,那么子对象、孙对象等各级下级对象都会继承该联系人。例如,如果您将联系人与架构相关联,则默认情况下,架构中的所有表都会继承该联系人。

如果子对象具有相同目的的联系人,则联系人继承将被覆盖。例如,假设有人将以下两个联系人与包含 t1 表的 ac_sch 架构相关联:

联系人

目的

data_stewards

管理员

business_unit1

批准者

现在,假设有人出于访问批准的目的将联系人 finance_deptt1 关联。与 t1 关联的联系人现在如下:

联系人

目的

data_stewards

管理员

finance_dept

批准者

The contact responsible for access approval on the ac_sch has been replaced with a contact directly associated with t1, but t1 continues to inherit the data_stewards contact from the schema.

All objects inherit contacts set on the account unless overridden by an association further down in the inheritance hierarchy.

受支持对象

您可以将联系人与以下对象关联:

  • 数据库

  • 架构

  • Apache Iceberg™ 表

  • 外部表

  • 动态表

  • 事件表

  • 视图

  • 物化视图

  • 任务(仅限 SQL)

创建联系人

When you create a contact, you specify the name of the contact and how the contact can be reached. Communication methods include the following:

  • 网站的 URL。

  • 电子邮件地址,可以是通讯组列表。

  • Snowflake 用户列表。

You can create a contact using Snowsight or SQL.

小技巧

Creating all contacts in a dedicated schema can be helpful.

Snowsight:
  1. Sign in to Snowsight.

  2. In the navigation menu, select Catalog » Database Explorer.

  3. 导航到要创建联系人的架构。

  4. Select Create » Contact.

  5. 指定联系人的姓名。

  6. Choose a communication method, then specify the email address, users, or URL of the people who can be contacted for assistance with an object.

  7. 选择能够将联系人与对象关联的角色。联系人授予这些角色 APPLY 权限。

  8. 选择 Create

SQL:

您可以执行 CREATE CONTACT 命令来创建新联系人。

示例

为通过其网站联系的支持团队创建联系人。

CREATE CONTACT support_dept URL = 'http://internalsupport.example.com';

为财务团队创建一个通过电子邮件地址联系的联络方式,该邮箱将作为分发列表使用。

CREATE CONTACT finance_dept EMAIL_DISTRIBUTION_LIST = 'fd_dl@example.com';

为数据库管理员创建联系人,以其 Snowflake 用户对象的名称进行标识。

CREATE CONTACT db_admins USERS = ('ex_admin1', 'ex_admin2');

将联系人与对象关联

When you associate a contact with an object, you specify the name of the contact along with the purpose of the association between the contact and the object. When users view all of the contacts associated with an object, they'll be able to decide who to communicate with based on the purpose of each contact. If a Snowflake feature uses the contact to reach people, it will be able to select the right contacts based on the purpose.

将联系人与对象关联的目的可以是以下其中之一:

目的

描述

SQL 值

批准者

批准或拒绝访问数据的请求。

ACCESS_APPROVAL

Security and compliance

Receives security and compliance updates.

SECURITY_COMPLIANCE

Data steward

提供有关数据的准确性、一致性和可靠性的信息。

STEWARD

支持

提供与数据集相关的技术支持。

SUPPORT

修改现有对象或创建新对象时,您可以关联联系人并定义其目的。

将联系人与现有对象关联

Snowsight:
  1. Sign in to Snowsight.

  2. In the navigation menu, select Catalog » Database Explorer.

  3. 导航到其中一个 支持的对象

  4. 选择 Details 选项卡。

  5. 找到 Assigned Contacts 部分并选择 Edit 图标。

  6. 为一个或多个目的选择联系人。例如,如果您从 Approver 下拉列表中选择联系人,则数据用户将在需要访问该对象时联系该联系人。

  7. 选择 Save

SQL:

现有对象的 ALTER ... SET CONTACT 命令允许您关联联系人并指定该对象的联系目的。关联联系人的语法对所有可关联联系人的对象都相同:

ALTER <object_type> <object_name>
  SET CONTACT <purpose> = <contact_name> [ , <purpose> = <contact_name> ... ]

purpose 必须是 预定义的目的 之一,用于描述联系人与对象的关系。当用户查看对象的联系人时,他们使用目的来确定要与哪些联系人通信。

示例

finance_dept 联系人与表格关联,以便用户知道在需要访问表格时应与谁通信:

ALTER TABLE t1 SET CONTACT ACCESS_APPROVAL = finance_dept;

Associate the security_officers contact with the account so Snowflake features can send updates related to security and compliance:

ALTER ACCOUNT SET CONTACT SECURITY_COMPLIANCE = security_officers;

data_stewards 联系人与架构关联,这样用户就架构中表的对象标记知道该与谁通信:

ALTER SCHEMA sch1 SET CONTACT STEWARD = data_stewards;

备注

如果要对现有 Iceberg 表、外部表或动态表设置联系人,则必须使用 ALTER TABLE 命令。

创建新对象时关联联系人

CREATE ... WITH CONTACT 命令允许您将联系人与新对象相关联。对于所有可以与联系人关联的对象,WITH CONTACT 子句的语法是相同的:

WITH CONTACT ( <purpose> = <contact_name> [ , <purpose> = <contact_name> ... ] )

purpose 必须是 预定义的目的 之一,用于描述联系人与对象的关系。当用户查看对象的联系人时,他们使用目的来确定要与哪些联系人通信。

对于表和类似表的对象,WITH CONTACT 子句在列定义之后指定。

The organization administrator can't associate a contact when creating an account.

示例

finance_dept 联系人与新表格相关联,以便用户知道在需要访问表格时应与谁通信:

CREATE TABLE t1 (col1 VARCHAR, col2 INT) WITH CONTACT (ACCESS_APPROVAL = finance_dept);

data_stewards 联系人与新架构相关联,以便用户知道在架构中表的对象标记方面应与谁通信;将 finance_dept 联系人与新架构相关联,以便用户知道在需要访问时应与谁通信:

CREATE SCHEMA sch1 WITH CONTACT (STEWARD = data_stewards, ACCESS_APPROVAL = finance_dept);

将联系人与对象分离

Snowsight:
  1. Sign in to Snowsight.

  2. In the navigation menu, select Catalog » Database Explorer.

  3. 导航到对象。

  4. 选择 Details 选项卡。

  5. 找到 Assigned Contacts 部分并选择 Edit 图标。

  6. 找到您要分离的联系人的目的(例如 Approver),然后使用下拉列表选择 None

  7. 选择 Save

SQL:

ALTER ... UNSET CONTACT command lets you detach a contact from an object. The syntax to detach the contact is the same for all objects that can be associated with a contact:

ALTER <object_type> <object_name>
  UNSET CONTACT <purpose>

您可以通过指定联系人和对象之间的关联目的来确定要分离的联系人,而不是通过联系人姓名。有关可以指定用于分离联系人的可能目的的列表,请参阅 预定义的目的

For example, to detach the contact that was added as the STEWARD of a table, run:

ALTER TABLE t1 UNSET CONTACT STEWARD;

备注

如果要对现有 Iceberg 表、外部表或动态表取消设置联系人,则必须使用 ALTER TABLE 命令。

查看对象的联系人

Snowsight:

当您导航到 Snowsight 中的某个对象时,与该对象关联的联系人会显示在 Details 选项卡上。

SQL:

对某个对象具有至少一项权限的用户可以使用 GET_CONTACTS 表格功能查看与该对象关联的联系人。该函数为与该对象关联的每个联系人返回一行。

例如,要列出表 t1 中的联系人,至少具有一项权限的用户可以执行以下操作:

SELECT *
  FROM TABLE(SNOWFLAKE.CORE.GET_CONTACTS('t1', 'TABLE'));

对于每个联系人,该函数列出了以下内容:

  • 联系的目的。

  • 联系人的通信方式。

  • 联系人是直接与对象关联还是继承自父对象。

治理联系人及其关联

Snowsight:

要列出在架构中创建的联系人并深入了解特定联系人的详细信息,请执行以下操作:

  1. Sign in to Snowsight.

  2. In the navigation menu, select Catalog » Database Explorer, and then select the schema.

  3. 选择 Contacts 选项卡。

  4. 如果要查看联系人的详细信息,包括与之关联的对象,请选择该联系人。

SQL:

ACCOUNT_USAGE 架构提供以下视图来帮助管理联系人:

访问控制权限

以下内容总结了用户使用联系人所需的权限。

任务

所需权限

创建联系人

以下两项兼具:

  • 架构的 CREATE CONTACT

  • 架构和数据库的 USAGE

将联系人与对象关联

以下任一内容:

  • 账户的 APPLY CONTACT 权限

  • 联系人 OWNERSHIP 对象的 APPLY 权限

列出对象的联系人

对象的任意权限。

将联系人与对象分离

以下任一内容:

  • 账户的 APPLY CONTACT 权限

  • 联系人 OWNERSHIP 对象的 APPLY 权限

修改现有联系人

以下任一内容:

  • 联系人的 OWNERSHIP

  • 联系人的 MODIFY

移除联系人

联系人的 OWNERSHIP