在Impala中,可以使用CREATE TABLE語句來創建臨時表。創建臨時表的語法如下:
CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name [(col_name data_type [COMMENT ‘col_comment’] [col_constraint_spec] [,…])] [COMMENT ‘table_comment’] [PARTITIONED BY (col_name data_type [COMMENT ‘col_comment’] [col_constraint_spec] [,…])] [CLUSTERED BY (col_name,…) [SORTED BY (col_name [ASC|DESC],…)] INTO num_buckets BUCKETS] [STORED AS file_format] [LOCATION ‘hdfs_path’] [TBLPROPERTIES (‘key1’=‘value1’, ‘key2’=‘value2’, …)] [AS select_statement]
其中,CREATE TEMPORARY TABLE語句創建的是臨時表。臨時表在Impala會話結束時被自動刪除。如果需要在多個Impala會話之間共享臨時表,可以使用CREATE TABLE語句創建一個普通表,并在使用完后手動刪除。