SHOW VIEWS¶
列出您具有访问权限的视图,包括安全视图。该命令可用于列出当前/指定数据库或架构的视图,或整个账户的视图。
输出返回视图元数据和属性,根据数据库、架构和视图名称按字典顺序排序。如果您希望使用提供的筛选器筛选结果,请务必注意这一点。
- See also:
ALTER VIEW , CREATE VIEW , DROP VIEW , DESCRIBE VIEW
VIEWS view (Information Schema)
语法
参数
TERSE(可选)仅返回输出列的子集:
created_onnamekinddatabase_nameschema_name
默认:无值(所有列都包含在输出中)
LIKE 'pattern'Optionally filters the command output by object name. The filter uses case-insensitive pattern matching, with support for SQL wildcard characters (
%and_).For example, the following patterns return the same results:
... LIKE '%testing%' ...... LIKE '%TESTING%' ...
Default: No value (no filtering is applied to the output).
IN ACCOUNT | [ DATABASE ] db_name | [ SCHEMA ] schema_name | [ APPLICATION ] application_name | [ APPLICATION PACKAGE ] application_package_name(可选)指定命令范围,该范围决定该命令是仅列出当前/指定数据库或架构的记录,还是列出整个账户的记录:
The
APPLICATIONandAPPLICATION PACKAGEkeywords are not required, but they specify the scope for the named Snowflake Native App.The
DATABASEorSCHEMAkeyword is not required; you can set the scope by specifying only the database or schema name. Likewise, the database or schema name is not required if the session currently has a database in use:- If
DATABASEorSCHEMAis specified without a name and the session does not currently have a database in use, the parameter has no effect on the output. - If
SCHEMAis specified with a name and the session does not currently have a database in use, the schema name must be fully qualified with the database name (e.g.testdb.testschema).
默认:取决于会话当前是否正在使用数据库:
- Database:
DATABASEis the default (i.e. the command returns the objects you have privileges to view in the database). - No database:
ACCOUNTis the default (i.e. the command returns the objects you have privileges to view in your account).
- If
STARTS WITH 'name_string'Optionally filters the command output based on the characters that appear at the beginning of the object name. The string must be enclosed in single quotes and is case sensitive.
For example, the following strings return different results:
... STARTS WITH 'B' ...... STARTS WITH 'b' ...
Default: No value (no filtering is applied to the output)
LIMIT rows [ FROM 'name_string' ]Optionally limits the maximum number of rows returned, while also enabling “pagination” of the results. The actual number of rows returned might be less than the specified limit. For example, the number of existing objects is less than the specified limit.
The optional
FROM 'name_string'subclause effectively serves as a “cursor” for the results. This enables fetching the specified number of rows following the first row whose object name matches the specified string:- The string must be enclosed in single quotes and is case sensitive.
- The string does not have to include the full object name; partial names are supported.
Default: No value (no limit is applied to the output)
Note
For SHOW commands that support both the
FROM 'name_string'andSTARTS WITH 'name_string'clauses, you can combine both of these clauses in the same statement. However, both conditions must be met or they cancel out each other and no results are returned.In addition, objects are returned in lexicographic order by name, so
FROM 'name_string'only returns rows with a higher lexicographic value than the rows returned bySTARTS WITH 'name_string'.For example:
... STARTS WITH 'A' LIMIT ... FROM 'B'would return no results.... STARTS WITH 'B' LIMIT ... FROM 'A'would return no results.... STARTS WITH 'A' LIMIT ... FROM 'AB'would return results (if any rows match the input strings).
输出
命令输出在以下列中提供视图属性和元数据:
| Column | Description |
|---|---|
| created_on | The timestamp at which the view was created. |
| name | The name of the view. |
| reserved | (Reserved for future use.) |
| kind | The kind of view, either VIEW or MATERIALIZED_VIEW. |
| database_name | The name of the database in which the view exists. |
| schema_name | The name of the schema in which the view exists. |
| owner | The owner of the view. |
| comment | Optional comment. |
| text | The text of the command that created the view (e.g. CREATE VIEW …). |
| is_secure | True if the view is a secure view; false otherwise. |
| is_materialized | True if the view is a materialized view; false otherwise. |
| owner_role_type | The type of role that owns the object, for example ROLE. If a Snowflake Native App owns the object, the value is APPLICATION. Snowflake returns NULL if you delete the object because a deleted object does not have an owner role. |
| change_tracking | Either ON or OFF. ON indicates enabled, and you query the change tracking data using streams or the CHANGES clause for SELECT statements. OFF indicates disabled, but you can optionally enable change tracking as needed. |
使用说明
- By design, the command output includes secure views, but does not provide certain information about these views unless you are using the role that has ownership of the view. To view details for secure views, you must use the role that owns the view or use the VIEWS view in the Information Schema.
- The output of this command might include objects with names like
SN_TEMP_OBJECT_n(wherenis a number). These are temporary objects that are created by the Snowpark library on behalf of the user.
- The command doesn’t require a running warehouse to execute.
- The command only returns objects for which the current user’s current role has been granted at least one access privilege.
- The MANAGE GRANTS access privilege implicitly allows its holder to see every object in the account. By default, only the account administrator (users with the ACCOUNTADMIN role) and security administrator (users with the SECURITYADMIN role) have the MANAGE GRANTS privilege.
-
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, specifySELECT "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.
-
The value for
LIMIT rowscan’t exceed10000. IfLIMIT rowsis omitted, the command results in an error if the result set is larger than ten thousand rows.To view results for which more than ten thousand records exist, either include
LIMIT rowsor query the corresponding view in the Snowflake Information Schema.
示例
Show all views whose names start with line that you have privileges to see in the mydb.public schema: