CREATE VIEW¶
Applies to
Hive SQL
Spark SQL
Databricks SQL
Warning
This grammar is partially supported in Snowflake. Translation pending for these CREATE VIEW elements:
[ [ GLOBAL ] TEMPORARY ]
[ TBLPROPERTIES ( property_name = property_value [ , ... ] ) ]
Description¶
Views are based on the result-set of an
SQL
query.CREATE VIEW
constructs a virtual table that has no physical data therefore other operations likeALTER VIEW
andDROP VIEW
only change metadata. (Spark SQL Language Reference CREATE VIEW (https://spark.apache.org/docs/latest/sql-ref-syntax-ddl-create-view.html))
Grammar Syntax ¶
CREATE [ OR REPLACE ] [ [ GLOBAL ] TEMPORARY ] VIEW [ IF NOT EXISTS ] view_identifier
create_view_clauses AS query
create_view_clauses :=
[ ( column_name [ COMMENT column_comment ], ... ) ]
[ COMMENT view_comment ]
[ TBLPROPERTIES ( property_name = property_value [ , ... ] ) ]
Sample Source Patterns¶
OR REPLACE¶
Note
This clause is fully supported in Snowflake
TEMPORARY (non-GLOBAL) VIEW¶
Note
This clause is fully supported in Snowflake
IF NOT EXISTS¶
Note
This clause is fully supported in Snowflake
Columns list¶
Note
This clause is fully supported in Snowflake
COMMENT clause¶
Input Code:¶
Output Code:¶