ALTER NOTEBOOK

Modifies the properties of an existing notebook.

语法

ALTER NOTEBOOK [ IF EXISTS ] <name> RENAME TO <new_name>

ALTER NOTEBOOK [ IF EXISTS ] <name> SET
  [ COMMENT = '<string_literal>' ]
  [ QUERY_WAREHOUSE = <warehouse_to_run_nb_and_sql_queries_in> ]
  [ IDLE_AUTO_SHUTDOWN_TIME_SECONDS = <number_of_seconds> ]
  [ SECRETS = ('<secret_variable_name>' = <secret_name>) [ , ... ] ]

参数

name

指定要更改的笔记本的标识符。

If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.

For more information, see Identifier requirements.

RENAME TO new_name

Changes the name of the notebook to new_name. The new identifier must be unique for the schema.

For more details about identifiers, see Identifier requirements.

You can move the object to a different database and/or schema while optionally renaming the object. To do so, specify a qualified new_name value that includes the new database and/or schema name in the form db_name.schema_name.object_name or schema_name.object_name, respectively.

Note

  • The destination database and/or schema must already exist. In addition, an object with the same name cannot already exist in the new location; otherwise, the statement returns an error.
  • Moving an object to a managed access schema is prohibited unless the object owner (that is, the role that has the OWNERSHIP privilege on the object) also owns the target schema.

重命名对象时,引用该对象的其他对象必须使用新名称进行更新。

SET ...

为笔记本设置一个或多个指定的属性或参数:

QUERY_WAREHOUSE = warehouse_name

指定运行笔记本中 SQL 查询的仓库。此参数是可选的。但是,需要运行 EXECUTE NOTEBOOK 命令。

IDLE_AUTO_SHUTDOWN_TIME_SECONDS = number_of_seconds

笔记本自动关闭前的空闲时间秒数。此参数适用于在仓库和容器运行时上运行的笔记本。值必须是介于 60 和 259200(72 小时)之间的整数。

默认值:3600 秒

SECRETS = '(secret_variable_name' = secret_name [ , ... ])

为笔记本设置密钥变量。

  • secret_variable_name - The variable that will be used in the notebook cell when retrieving information from the secret.
  • secret_name - The name of the Snowflake secret.
UNSET ...

取消设置笔记本的一个或多个指定属性或参数,以将属性重置为默认值:

  • QUERY_WAREHOUSE
  • COMMENT

To unset multiple properties or parameters with a single ALTER statement, separate each property or parameter with a comma.

When unsetting a property or parameter, specify only the property or parameter name (unless the syntax above indicates that you should specify the value). Specifying the value returns an error.

访问控制要求

A role used to execute this operation must have the following privileges at a minimum:

权限对象备注
USAGE 或 OWNERSHIP笔记本OWNERSHIP 是对对象的特殊权限,会自动向对象的创建角色授予。

Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema.

For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.

For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

使用说明

  • 关于元数据:

    Attention

    Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.

示例

The following example renames the notebook named my_notebook to notebook_v2:

ALTER NOTEBOOK my_notebook RENAME TO notebook_v2;

以下示例取消设置了 QUERY_WAREHOUSE 属性:

ALTER NOTEBOOK my_notebook UNSET QUERY_WAREHOUSE;