DESCRIBE VIEW¶
描述视图(或表)中的列。
DESCRIBE 可以缩写为 DESC。
语法¶
DESC[RIBE] VIEW <name>
参数¶
name指定要描述的视图的标识符。如果标识符包含空格或特殊字符,则整个字符串必须放在双引号内。放在双引号内的标识符也区分大小写。
使用说明¶
命令输出不包括视图定义。请改用 SHOW VIEWS。
DESC VIEW 和 DESCRIBE TABLE 可互换。任一命令检索与语句中的条件匹配的表或视图的详细信息。
输出返回一个
POLICY NAME列,用于指示在列上设置的 掩码策略。如果未在该列上设置掩码策略,或者 Snowflake 账户不是 Enterprise Edition 或更高版本,Snowflake 将返回
NULL。
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.
示例¶
示例设置:
CREATE VIEW emp_view AS SELECT id "Employee Number", lname "Last Name", location "Home Base" FROM emp;
描述视图:
DESC VIEW emp_view; +-----------------+--------------+--------+-------+---------+-------------+------------+-------+------------+---------+-------------+-----------------+ | name | type | kind | null? | default | primary key | unique key | check | expression | comment | policy name | privacy domain | |-----------------+--------------+--------+-------+---------+-------------+------------+-------+------------+---------+-------------+-----------------+ | Employee Number | NUMBER(38,0) | COLUMN | Y | NULL | N | N | NULL | NULL | NULL | NULL | NULL | | Last Name | VARCHAR(50) | COLUMN | Y | NULL | N | N | NULL | NULL | NULL | NULL | NULL | | Home Base | VARCHAR(100) | COLUMN | Y | NULL | N | N | NULL | NULL | NULL | NULL | NULL | +-----------------+--------------+--------+-------+---------+-------------+------------+-------+------------+---------+-------------+-----------------+