SHOW NOTEBOOKS

列出您具有访问权限的 笔记本

您可以使用此命令列出会话的当前数据库和架构、指定的数据库或架构或整个账户中的对象。

输出包括每个对象的元数据和属性。对象按数据库、架构和对象名称以字典顺序排序(有关输出列的说明,请参阅本主题中的 输出)。如果要筛选结果,请务必注意顺序。

语法

SHOW NOTEBOOKS [ LIKE '<pattern>' ]
               [ IN
                     {
                       ACCOUNT                  |

                       DATABASE                 |
                       DATABASE <database_name> |

                       SCHEMA                   |
                       SCHEMA <schema_name>     |
                       <schema_name>
                     }
               ]
               [ STARTS WITH '<name_string>' ]
               [ LIMIT <rows> ]
               [ LIMIT <rows> [ FROM '<name_string>' ] ]
Copy

参数

LIKE 'pattern'

(可选)按对象名称筛选命令输出。筛选器使用 不区分大小写 的模式匹配,并支持 SQL 通配符(%_)。

例如,以下模式返回 相同的 结果:

... LIKE '%testing%' ...
... LIKE '%TESTING%' ...

. 默认:无值(不对输出应用筛选)。

[ IN ... ]

(可选)指定命令的作用域。指定以下任一项:

ACCOUNT

返回整个账户的记录。

DATABASE. DATABASE db_name

返回当前正在使用的数据库或指定数据库 (db_name) 的记录。

如果指定 DATABASE 而不指定 db_name,并且没有使用任何数据库,则关键字对输出没有影响。

备注

在数据库上下文中使用不带 IN 子句的 SHOW 命令,这样可能会导致结果低于预期。

如果不使用 IN 子句,则具有相同名称的多个对象只会显示一次。例如,如果您在 schema1 中具有表 t1 且在 schema2 中具有表 t1,并且两者都在您指定的数据库上下文的作用域内(即,您所选的数据库是 schema1schema2 的父级),则 SHOW TABLES 只会显示其中一个 t1 表。

SCHEMA. SCHEMA schema_name

返回当前正在使用的架构或指定架构 (schema_name) 的记录。

如果数据库正在使用中,或者指定了完全限定 schema_name (例如 db.schema),则 SCHEMA 是可选选项。

如果未使用任何数据库,则指定 SCHEMA 对输出没有影响。

If you omit IN ..., the scope of the command depends on whether the session currently has a database in use:

  • If a database is currently in use, the command returns the objects you have privileges to view in the database. This has the same effect as specifiying IN DATABASE.

  • If no database is currently in use, the command returns the objects you have privileges to view in your account. This has the same effect as specifiying IN ACCOUNT.

STARTS WITH 'name_string'

(可选)根据对象名称开头显示的字符筛选命令输出。该字符串必须放在单引号内并且 区分大小写

例如,以下字符串会返回 不同的 结果:

... STARTS WITH 'B' ...
... STARTS WITH 'b' ...

. 默认:无值(不对输出应用筛选)

LIMIT rows

(可选)限制返回的最大行数。返回的实际行数可能小于指定的限制。例如,现有对象的数量小于指定的限制。

默认:无值(不对输出应用限制)。

输出

命令的输出包括以下列,它们描述了对象的属性和元数据:

描述

created_on

创建笔记本时的日期和时间。

name

笔记本对象的名称。

database_name

存储笔记本的数据库。

schema_name

存储笔记本的架构。

comment

笔记本对象的注释。

owner

拥有笔记本对象的角色。

query_warehouse

运行笔记本中发出的查询的仓库。

url_id

与笔记本对象关联的唯一 ID。

owner_role_type

拥有对象的角色类型,例如 ROLE. 如果 Snowflake Native App 拥有该对象,则该值为 APPLICATION. 如果您删除该对象,则 Snowflake 会返回 NULL,原因是删除的对象不具有所有者角色。

code_warehouse

运行笔记本内核的仓库。

访问控制要求

用于执行此操作的 角色 必须至少具有以下 权限

权限

对象

备注

USAGE 或 OWNERSHIP

笔记本

OWNERSHIP is a special privilege on an object that is automatically granted to the role that created the object, but can also be transferred using the GRANT OWNERSHIP command to a different role by the owning role (or any role with the MANAGE GRANTS privilege).

使用说明

  • 该命令不需要正在运行的仓库即可执行。

  • 该命令仅返回当前用户的当前角色已获授至少一项访问权限的对象。

  • MANAGE GRANTS 访问权限隐式允许其持有者查看账户中的每个对象。默认情况下,只有账户管理员(具有 ACCOUNTADMIN 角色的用户)和安全管理员(具有 SECURITYADMIN 角色的用户)才具有 MANAGE GRANTS 权限。

  • To post-process the output of this command, you can use the pipe operator (->>) or the RESULT_SCAN function. Both constructs treat the output as a result set that you can query.

    The output column names for this command are generated in lowercase. If you consume a result set from this command with the pipe operator or the RESULT_SCAN function, use double-quoted identifiers for the column names in the query to ensure that they match the column names in the output that was scanned. For example, if the name of an output column is type, then specify "type" for the identifier.

  • 该命令 最多 返回指定对象类型的 1 万条记录,由用于执行命令的角色的访问权限决定。即使应用了筛选器,也不会返回任何超出 1 万条限制后的记录。

    要查看存在超过 1 万条记录的结果,请在 Snowflake Information Schema 中查询相应的视图(如果存在)。

示例

以下示例列出了您有权在当前架构中查看的笔记本:

SHOW NOTEBOOKS;
Copy

以下示例列出了名称以 test 开头的笔记本:

SHOW NOTEBOOKS STARTS WITH 'test';
Copy

返回:

+--------------------------------+--------------+---------------+----------------------------------------------------------------------------------+--------+-----------------+----------------------+-----------------+------------------------------+
| created_on                     | name         | database_name | schema_name | comment                                                            | owner  | query_warehouse | url_id               | owner_role_type | code_warehouse               |
+--------------------------------+--------------+---------------+----------------------------------------------------------------------------------+--------+-----------------+----------------------+-----------------+------------------------------+
|  2024-03-20 06:37:08.402 +0000 | test_notebook| PUBLIC        | PUBLIC      | {"lastUpdatedUser":"309334439262","lastUpdatedTime":1711566800002} | PUBLIC | HLEVE1          | 2mbdchin3kn2tlzgqtca | ROLE            | SYSTEM$STREAMLIT_NOTEBOOK_WH |
+--------------------------------+--------------+---------------+-------------+--------------------------------------------------------------------+--------+-----------------+----------------------+-----------------+------------------------------+
语言: 中文