工作区

重要

Starting in September 2025, Snowflake is gradually upgrading accounts from Worksheets to Workspaces. Workspaces will become the default SQL editor. For more information, see 将账户从 Worksheets 默认设置为 Workspaces.

概述

工作区提供了一个统一编辑器,用于创建、整理和管理跨多种文件类型的代码,可用于分析数据、开发模型和构建管道。

工作区 由您专有,它提供了一个开发环境,可供您在其中构建、实验和测试自己的工作。工作区中的所有内容均基于文件,这使您可以处理更复杂的项目,并轻松与 Git 集成,以实现版本控制、开展协作并与现有工作流程保持一致。

在用户首次访问工作区时,Snowflake 会自动创建一个特定于用户的内部数据库(以前称为 个人数据库)。该数据库专门用于存储工作区,不能包含表或视图等标准对象。除了启用工作区功能外,它不会向用户授予任何其他功能或权限。

管理员可能会注意到,用户似乎拥有该数据库的 OWNERSHIP、USAGE、CREATE 和 SCHEMA 权限。这些是与工作区交互所必需的权限,不会影响对其他资源的访问。

工作区环境

工作区是一种新的编辑器,由六个部分或 窗格 组成:

工作区环境概述。
  1. 工作区: 一个可存放所有文件和文件夹的区域。拖动文件即可在文件夹之间移动文件。使用嵌套文件夹将相关工作表分组到逻辑类别下,这样无需在扁平列表中搜索即可快速找到特定工作表。每个用户都有一个名为“My Workspace”的默认工作区,该工作区由 Snowflake 自动配置。您也可以通过在 Workspaces 菜单中选择 + Add New 来创建新的工作区。默认工作区不能删除或重命名。

  2. 工作表: 打开和编辑您拥有或拥有任何权限的工作表。请注意,如果您仅拥有工作表的编辑权限,则编辑内容不会得到保存。要将工作表转换为工作区中的文件,请将其拖动到工作区内的文件夹。工作区查询的运行方式与工作表类似,但有一些细微区别,包括 UI 性能更高,以及能从同一个 SQL 文件同时运行两个查询。

  3. Database Explorer: A hierarchical view of all databases in your account, the schemas for each database, and other objects, organized by type. Use the filter to search for objects. You can also filter out unusable objects to simplify your view by selecting Show databases I can query. The options available in the vertical ellipsis 工作表的更多操作 (more actions) button vary by object type, but include features such as placing names in the editor, copying names, and viewing definitions. To open or close the Database Explorer or File Explorer, select the File Explorer icon 文件资源管理器 in the bottom toolbar of the Workspaces window.

  4. 编辑器: 编辑查询,以及将多个文件置于并排拆分视图中,以便同时查看这些文件。使用内嵌 Copilot 直接在编辑器工作区中获取建议和完成内容。

  5. 结果: 将结果置于并排拆分视图中,或者固定结果以便于比较。

  6. 查询历史记录: 查看您已运行的所有查询的历史记录。Current File 显示当前在编辑器中打开和选定的文件中的历史查询。筛选到当前文件或所有文件。All Files 显示您在所有文件中运行的所有历史查询。要打开或关闭此视图,请选择“Workspaces”窗口底部工具栏中的 Query History 图标 查询历史记录

Manage access and behavior

As an administrator, you can manage the transition to Workspaces through Snowsight or using SQL commands. You can set the default editor for SQL queries, disable the Workspaces feature, and address potential conflicts with existing security policies.

Set or revert the default editor

To set Workspaces as the account-wide default editor for all users from Snowsight, follow these steps:

  1. Sign in to Snowsight as ACCOUNTADMIN.

  2. In the lower-left corner, select your name » Settings.

  3. Under Account, choose General.

  4. Enable the Set Workspaces as default SQL editor for the account option.

    Administrators can revert to Worksheets as the default editor by disabling this option. If users want to revert to Worksheets, they can also select Go to Worksheets from the Workspaces UI:

    Select ellipsis menu and select Go to Worksheets

    Or toggle the user setting in the Workspaces editor:

    Use Workspaces as the default SQL editor

To set the account-wide default editor to be Workspaces for all users using SQL:

ALTER ACCOUNT SET USE_WORKSPACES_FOR_SQL = 'always';
Copy

To revert this setting and use the previous default editor, but respect any Snowflake-managed BCR that makes Workspaces the default, run this command:

ALTER ACCOUNT UNSET USE_WORKSPACES_FOR_SQL;
Copy

To revert to the previous editor and temporarily ignore any Snowflake-managed BCR that makes Workspaces the default, run this command:

ALTER ACCOUNT SET USE_WORKSPACES_FOR_SQL = 'never';
Copy

备注

Worksheets will eventually become deprecated and the command above will no longer work. If you had previously set this parameter, it will be automatically cleared once Worksheets is deprecated. Snowflake will provide advance notice when a deprecation date is available. For more information, see 将账户从 Worksheets 默认设置为 Workspaces.

Disable Workspaces

To disable Workspaces, set the ENABLE_PERSONAL_DATABASE account-level parameter to FALSE, run this command:

ALTER ACCOUNT SET ENABLE_PERSONAL_DATABASE = FALSE;
Copy

此参数需要 ACCOUNTADMIN 权限。将其设置为 FALSE 之后,工作区将无法运行;但是,工作区仍将列在 Snowsight 导航菜单中。

限制

  • 工作区不支持共享。

  • 查询筛选器 不受支持。任何包含筛选器的查询都将失败。

  • 工作区文件不会包含在 Universal Search 结果中。

  • 在新工作区 UI 和旧工作表 UI 中同时打开和编辑同一个工作表可能会导致更改丢失。

  • 对于工作表,新工作区 UI 和旧工作表 UI 中的执行上下文设置(角色、仓库和命名空间)不同步。

语言: 中文