Constructs a virtual table that has no physical data based on the result-set of a SQL query. ALTER VIEW
and DROP VIEW
only change metadata.
Syntax
CREATE [ OR REPLACE ] [ TEMPORARY ] VIEW [ IF NOT EXISTS ] view_name [ column_list ] [ COMMENT view_comment ] [ TBLPROPERTIES clause ] AS query column_list ( { column_alias [ COMMENT column_comment ] } [, ...] )
ตัวอย่าง
%sql CREATE OR REPLACE TEMPORARY VIEW demo_tmp2(name, value) AS VALUES ("Yi", 1), ("Ali", 2), ("Selina", 3)
หรือใช้คำว่า TEMP
แทน TEMPORARY
ก็ได้
%sql CREATE OR REPLACE TEMP VIEW demo_tmp1(name, value) AS VALUES ("Yi", 1), ("Ali", 2), ("Selina", 3)