comment '在hive中comment是注释代码的意思'
create database house;
use house;
comment '注意:创建表的语句,要一句一句的拷贝'
create table king_county_house(
selling_price double,
bedrooms_num double,
bathroom_num double,
housing_area double,
parking_area double,
floor_num double,
housing_rating double,
built_area double,
basement_area double,
year_built int,
year_repair int,
latitude double,
longtitude double,
sale_data string
)
row format delimited fields terminated by ',';
上传house.csv
hdfs dfs -mkdir /data
hdfs dfs -put /root/data/house.csv /data
导入相应的表
hive>load data inpath '/data/house.csv' overwrite into table king_county_house;
comment '导入数据后,先设置hive为本地模式,才能执行select查询:'
hive> set hive.exec.mode.local.auto=true;
hive> select count(*) from king_county_house limit 10;
comment '查询结果为10001条数据。'