hive一些语句

row format delimited fields terminated by ' ' 创建表时以  作为分隔符

location '/student'创建表时设置表的路径

insert overwrite local directory
'/opt/module/hive/data/export/student'[ROW FORMAT DELIMITED FIELDS TERMINATED BY ' ']

select * from student;查询结果导出到本地

alter table student2 set tblproperties('EXTERNAL'='TRUE');修改student2 表为外部表

desc formatted student2;查看表结构

create table student2 as select * from student where name = 'zhoayi' 创建一个和student结构一样且name属性为‘zhaoyi’的表

truncate table student;删除表中数据

load data local inpath '/opt/module/datas/dept.txt' into table dept;加载本地(虚拟机)中的dept.txt文件到dept表中

 drop database db_hive [cascade];删除数据库【如不为空强制删除】

 collect_set(day_id)[0] as day_id 当将某个表查询到的东西加到另一个表时,且该表的某些字段不需要变化用这个。

create table saledl1 row format delimited fields terminated by ',' as select * from sales1 where sale_nbr like concat("C","%");hive里的正则匹配。

原文地址:https://www.cnblogs.com/zhaoyids/p/15349019.html