Hive查询可以以哪些子句开头

问题描述

要从Hive sql检索数据,查询的所有子句都可以以什么开头? 我只知道SELECTWITH。还有什么吗?

我没有看到类似CREATEDELETEALTER之类的东西。

这基本上是用来确定给定查询是否用于从表中读取数据(使用query.startsWith())。

提前谢谢!

解决方法

SQL查询可以以 WITH FROM SELECT 开头。

多插入看起来像这样:

[WITH...]
[FROM...]
INSERT OVERWRITE TABLE1 SELECT...
INSERT OVERWRITE TABLE2 SELECT...

可以省略,可以以FROM开头,可以为SELECT或INSERT ... SELECT。

此查询有效。它以FROM开头,不从表中读取数据

from (select current_timestamp ts) s
select ts

将相同的插入多个表中,当然示例被简化了,但是很有效

with mydata as (select current_timestamp ts)

from (select ts from mydata) s

insert into table1 
select ts

insert into table2
select ts
where ts = current_timestamp