hive建库信息查询:hadoop fs -ls /user/hive/warehouse
hive库表中信息查询:hadoop fs -ls /user/hive/warehouse/oa.db
Hive中可以使用UDF(User Defined Function)用户自定义函数,UDF函数可以直接应用于select语句,对查询结构进行格式化处理后输出。UDF函数需要注意:
--自定义UDF需要继承org.apache.hadoop.hive.ql.UDF;
--需要实现evaluate函数,evaluate函数可以重载。
从HDFS中导入数据至hive数据表:
LOAD DATA INPATH '/user_name.data.utf.txt' OVERWRITE INTO TABLE u_info
OVERWRITE表示加载的数据会覆盖原来的内容
对比本地的方式:LOAD DATA LOCAL INPATH
使用insert插入数据
执行命令插入,例如,insert into table 表名 select * from 表2 limit n;
动态分区插入,insert into table test1 partition(c) select * from test2;
通过一个表查询直接新建并插入表数据:create table test1 as select * from test2
数据导出:
1.将数据导出到本地文件:insert overwrite local directory '/home/aa/hive_text/1.txt' select * from test1
2.将数据导出到HDFS:insert overwrite directory '/hive/a' select * from test1