hive array基本操作:建表+查询+修改

数据准备

# cat /root/person.txt 
zhangsan        beijing,shanghai,tianjin,hangzhou
lisi    changchu,chengdu,wuhan

创建表

Create table users(name string, worklocations array<string> ) row format delimited fields terminated by '\t' collection items terminated by ','; 

导入数据


load data local inpath '/root/person.txt ' OVERWRITE INTO TABLE users; 

查询 array 数据类型字段的长度

select name,size(worklocations) from users;

查询 array 数据类型字段指定列的一行数据

select *from users where array_contains(worklocations,'beijing');

查看表结构

desc users;

修改列名称/类型

alter table users change column worklocations new array<string>

你可能感兴趣的:(hive)