SHOW DBT PROJECTS

列出您具有访问权限的 dbt project objects 对象。

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

The output includes the metadata and properties for each object. The objects are sorted lexicographically by database, schema, and object name (see Output in this topic for descriptions of the output columns). The order of rows in the results is important to note if you want to filter the results.

另请参阅:

CREATE DBT PROJECTALTER DBT PROJECTEXECUTE DBT PROJECTDROP DBT PROJECTSHOW DBT PROJECTS

语法

SHOW DBT PROJECTS [ 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 specifying 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 specifying IN ACCOUNT.

STARTS WITH 'name_string'

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

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

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

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

LIMIT rows

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

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

LIMIT rows [ FROM 'name_string' ]

(可选)限制返回的最大行数,同时还对结果启用“分页”功能。返回的实际行数可能小于指定的限制。例如,现有对象的数量小于指定的限制。

可选的 FROM 'name_string' 分子句实际上会充当结果的“游标”。这样就可以提取对象名称与指定字符串匹配的第一行之后的指定行数:

  • 该字符串必须放在单引号内并且 区分大小写

  • 该字符串不必包含完整的对象名称;支持部分名称。

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

备注

对于支持 FROM 'name_string'STARTS WITH 'name_string' 的 SHOW 子句,您可以将这两个子句组合在同一语句中。但是,两个条件都必须满足,否则它们相互抵消,不返回任何结果。

此外,对象按名称的字典顺序返回,因此 FROM 'name_string' 仅返回字典值高于 STARTS WITH 'name_string' 所返回行的行。

例如:

  • ... STARTS WITH 'A' LIMIT ... FROM 'B' 不会返回任何结果。

  • ... STARTS WITH 'B' LIMIT ... FROM 'A' 不会返回任何结果。

  • ... STARTS WITH 'A' LIMIT ... FROM 'AB' 将返回结果(如果有任何行与输入字符串匹配)。

输出

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

描述

external_access_integrations

The name of the external access integrations the dbt Project is permitted to use to pull remote dependencies from dbt package hub or Github.

name

dbt 项目对象的标识符。

database_name

定义 dbt 项目对象的数据库的名称。

schema_name

定义 dbt 项目对象的架构的名称。

created_on

创建 dbt 项目对象的日期和时间。

updated_on

上次更新 dbt 项目对象的日期和时间。

owner

拥有 dbt 项目对象的角色的名称。

comment

与 dbt 项目对象相关的注释。

dbt_snowflake_version

The Snowflake version the dbt project object is on.

default_target

The default execution target (for example, prod or dev) used by dbt commands executed through Snowflake.

The following columns provide the value of a deprecated parameter:

描述

default_version

The version of the dbt project object:

  • LAST: The most recent version of the dbt project object.

  • FIRST: The oldest version of the dbt project object.

default_version_name

The version identifier in the form VERSION$num, where num is a positive integer, for example: VERSION$1.

The version number begins at 1 when you create a dbt project object and increments by one with each new version of the dbt project object.

Snowflake increments the version identifier when you perform the following tasks:

  • Redeploy dbt project from a workspace (runs the ALTER command with the ADD VERSION option).

  • Update the project by using the ALTER DBT PROJECT command.

  • Run the Snow CLI snow dbt deploy command with the --force option.

Snowflake resets the version identifier to 1 and removes all version aliases when you run the CREATE DBT PROJECT command with the OR REPLACE option.

default_version_alias

The custom version name alias that you created for a specific version of the dbt project object using the ALTER DBT PROJECT command with the ADD VERSION option. A version name alias always maps to a specific version identifier, such as VERSION$3.

default_version_location_uri

The location URI of the default version. This is read only.

default_version_source_location_uri

The location URI of the default version’s source files in its Git object. If the dbt project object is not connected to a Git object, this is null.

dbt_snowflake_version

The Snowflake version the dbt project object is on.

访问控制要求

用于执行此 SQL 命令的 角色 必须至少具有以下 一项 权限

权限

对象

USAGE

dbt 项目

MONITOR

dbt 项目

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.

有关创建具有指定权限集的自定义角色的说明,请参阅 创建自定义角色

有关对 安全对象 执行 SQL 操作的相应角色和权限授予的一般信息,请参阅 访问控制概述

使用说明

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

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

  • 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.

    For example, you can use the pipe operator or RESULT_SCAN function to select specific columns from the SHOW command output or filter the rows.

    When you refer to the output columns, use double-quoted identifiers for the column names. For example, to select the output column type, specify SELECT "type".

    You must use double-quoted identifiers because the output column names for SHOW commands are in lowercase. The double quotes ensure that the column names in the SELECT list or WHERE clause match the column names in the SHOW command output that was scanned.

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

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

  • LIMIT rows 的值不能超过 10000。如果省略 LIMIT rows,若结果集大于 1 万行,则该命令将导致错误。

    要查看存在超过 1 万条记录的结果,请在 Snowflake Information Schema 中包含 LIMIT rows 或查询相应的视图。

示例

The following example lists the dbt project objects that you have privileges to view in the public schema of the my_db database:

SHOW DBT PROJECTS IN DATABASE my_db;
Copy
+-----------------------------+----------------+---------------+-------------+-------------------------------+-------------------------------+--------------+---------+-----------------+----------------------+-----------------------+------------------------------------------------------------+-------------------------------------+-----------------------+----------------+
| external_access_integrations |    name        | database_name | schema_name |          created_on           |          updated_on           |    owner     | comment | default_version | default_version_name | default_version_alias | default_version_location_uri                               | default_version_source_location_uri | dbt_snowflake_version | default_target |
+-----------------------------+----------------+---------------+-------------+-------------------------------+-------------------------------+--------------+---------|-----------------|----------------------|-----------------------+------------------------------------------------------------+-------------------------------------+-----------------------+----------------+
| my_ext_integration_1        | COSMOS         | MY_DB         | PUBLIC      | 2025-04-29 17:21:25.413 -0700 | 2025-04-29 17:21:29.462 -0700 | ACCOUNTADMIN |         | LAST            | VERSION$1            | null                  | snow://dbt/MY_DB.PUBLIC.COSMOS/versions/version$1/         | @s1                                 | 1.9.2b                | null           |
| my_ext_integration_1        | Jaffle_shop    | MY_DB         | PUBLIC      | 2025-03-25 12:36:16.574 -0700 | 2025-03-25 12:36:17.833 -0700 | ACCOUNTADMIN |         | LAST            | VERSION$1            | null                  | snow://dbt/MY_DB.PUBLIC.Jaffle_shop/versions/version$1/    | @s1                                 | 1.9.2b                | prod           |
| my_ext_integration_2        | MY_DBT_PROJECT | MY_DB         | PUBLIC      | 2025-05-02 13:42:36.306 -0700 | 2025-05-02 13:42:38.584 -0700 | ACCOUNTADMIN |         | LAST            | VERSION$1            | null                  | snow://dbt/MY_DB.PUBLIC.MY_DBT_PROJECT/versions/version$1/ | @s1                                 | 1.9.2b                | dev            |
| null                        | MY_SHOP        | MY_DB         | PUBLIC      | 2025-04-29 17:15:27.295 -0700 | 2025-04-29 17:15:28.709 -0700 | ACCOUNTADMIN |         | LAST            | VERSION$1            | null                  | snow://dbt/MY_DB.PUBLIC.MY_SHOP/versions/version$1/        | @s1                                 | 1.9.2b                | null           |
+-----------------------------+----------------+---------------+-------------+-------------------------------+-------------------------------+--------------+---------+-----------------+----------------------+-----------------------+------------------------------------------------------------+-------------------------------------+-----------------------+----------------+
语言: 中文