SHOW PROCEDURES¶
列出您有权访问的所有存储过程,包括内置过程和用户定义的过程。
对于仅列出用户定义的过程的命令,请参阅 SHOW USER PROCEDURES。
语法¶
SHOW PROCEDURES [ LIKE '<pattern>' ]
[ IN
{
ACCOUNT |
CLASS <class_name> |
DATABASE |
DATABASE <database_name> |
SCHEMA |
SCHEMA <schema_name> |
<schema_name>
APPLICATION <application_name> |
APPLICATION PACKAGE <application_package_name> |
}
]
参数¶
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
,并且两者都在您指定的数据库上下文的作用域内(即,您所选的数据库是schema1
和schema2
的父级),则 SHOW TABLES 只会显示其中一个t1
表。SCHEMA
、.SCHEMA schema_name
返回当前正在使用的架构或指定架构 (
schema_name
) 的记录。如果数据库正在使用中,或者指定了完全限定
schema_name
(例如db.schema
),则SCHEMA
是可选选项。如果未使用任何数据库,则指定
SCHEMA
对输出没有影响。
APPLICATION application_name
、.APPLICATION PACKAGE application_package_name
返回命名的 Snowflake Native App 或应用程序包的记录。
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
.
使用说明¶
该命令不需要正在运行的仓库即可执行。
该命令仅返回当前用户的当前角色已获授至少一项访问权限的对象。
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 中查询相应的视图(如果存在)。
如果指定
CLASS
,该命令将只返回以下列:| name | min_num_arguments | max_num_arguments | arguments | descriptions | language |
输出¶
命令输出在以下列中提供过程属性和元数据:
列 |
描述 |
---|---|
|
创建存储过程时的时间戳。 |
|
存储过程的名称。 |
|
存储过程所在架构的名称。 |
|
如果存储过程是内置的(而非用户定义的),则为 |
|
目前不适用。 |
|
如果存储过程是在 ANSI 标准中定义的,则为 |
|
最小实参数量。 |
|
最大实参数量。 |
|
实参和返回类型的数据类型。可选参数使用关键字 |
|
存储过程的描述。 |
|
存储过程所在数据库的名称。 |
|
如果存储过程返回表格数据,则为 |
|
目前不适用。 |
|
如果存储过程为安全存储过程,则为 |
示例¶
显示所有过程:
SHOW PROCEDURES;
此示例演示如何在具有参数的存储过程中使用 SHOW PROCEDURE
。此外还演示了如何限制过程列表,使其仅包含与指定正则表达式匹配的过程。
SHOW PROCEDURES LIKE 'area_of_%';
+-------------------------------+----------------+--------------------+------------+--------------+---------+-------------------+-------------------+------------------------------------+------------------------+-----------------------+-------------------+----------------------+-----------+
| created_on | name | schema_name | is_builtin | is_aggregate | is_ansi | min_num_arguments | max_num_arguments | arguments | description | catalog_name | is_table_function | valid_for_clustering | is_secure |
|-------------------------------+----------------+--------------------+------------+--------------+---------+-------------------+-------------------+------------------------------------+------------------------+-----------------------+-------------------+----------------------+-----------|
| 1967-06-23 00:00:00.123 -0700 | AREA_OF_CIRCLE | TEMPORARY_DOC_TEST | N | N | N | 1 | 1 | AREA_OF_CIRCLE(FLOAT) RETURN FLOAT | user-defined procedure | TEMPORARY_DOC_TEST_DB | N | N | N |
+-------------------------------+----------------+--------------------+------------+--------------+---------+-------------------+-------------------+------------------------------------+------------------------+-----------------------+-------------------+----------------------+-----------+
输出列类似于 SHOW FUNCTIONS 和 SHOW USER FUNCTIONS 的输出列。对于存储过程,其中一些列当前无意义(例如 is_aggregate
、valid_for_clustering
),但保留了这些列以供将来使用。