Hive命令记录

1.从CSV文件读取数据写入表中,指定分割符

# 建表
CREATE TABLE `my_table`(
  `city_id` string COMMENT 'city_id',
  `area_code` string COMMENT 'area ID',
  `prediction` int COMMENT 'date prediction',
  `vdate` string COMMENT 'date')
  row format delimited fields terminated by ',';
# 将本地数据写入数据库
LOAD DATA LOCAL INPATH '/home/yourcsvfile.csv' OVERWRITE INTO TABLE my_table;
# 将Hadoop文件写入数据库
LOAD DATA  INPATH 'hdfs:///user/yourcsvfile.csv' OVERWRITE INTO TABLE my_table;

2.从数据库查询数据并保存到本地

hive -e "set mapreduce.job.queuename=data_ai;select ...."  > xxxfile.csv