我正在学习Hive。假设我有如下表格,
t1
id name
1 ram
2 rahim
3 yesudas
4 george
5 yogesh
现在在sql中我会写,
select name
from t1
where name like 'r%'
将仅从r开始给出名称结果,
id name
1 ram
2 rahim
如何在Hive中实现这一点。请帮助
答案 0 :(得分:1)
表格创建:
create table t1 (id int,name string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE;
<强>查询:强>
select * from t1 where name like 'r%';
<强>输出:强>
1 ram
2 rahim
答案 1 :(得分:0)
您可以运行相同的查询。
蜂房&GT;
CREATE TABLE t1(
id int,
name string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n';
行 所用时间:0.625秒
hive> load data local inpath '/home/amit/data.txt' into table t1;
将数据加载到表eis_app.t1 表eis_app.t1统计数据:[numFiles = 1,totalSize = 44] 好 所用时间:1.22秒
hive> select * from t1;
OK
1 ram
2 rahim
3 yesudas
4 george
5 yogesh
Time taken: 0.098 seconds, Fetched: 5 row(s)
hive> select * from t1 where name like 'r%';
OK
1 ram
2 rahim
Time taken: 0.107 seconds, Fetched: 2 row(s)
hive>