impala 建表语句
时间: 2023-11-24 12:53:23 浏览: 83
以下是Impala建表语句的示例:
```sql
CREATE TABLE table_name (
column1_name column1_data_type,
column2_name column2_data_type,
...
) [PARTITIONED BY (partition_column_name partition_column_data_type, ...)]
[ROW FORMAT row_format]
[STORED AS file_format]
[TBLPROPERTIES (property_name=property_value, ...)];
```
其中,`table_name`是要创建的表的名称,`column_name`是表中的列名,`column_data_type`是列的数据类型。如果需要分区,则在`PARTITIONED BY`子句中指定分区列名和数据类型。`ROW FORMAT`和`STORED AS`子句用于指定表的存储格式和行格式。`TBLPROPERTIES`子句用于指定表的属性。
以下是一个示例:
```sql
CREATE TABLE employees (
id INT,
name STRING,
age INT,
salary FLOAT
) PARTITIONED BY (department STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
TBLPROPERTIES ("creator"="impala", "created_at"="2021-10-22");
```
阅读全文