标签:基本操作 logs file use str int field lin store
1、创建表
hive>CREATE TABLE userTables(id INT,name STRING);
或者
hive> CREATE TABLE userTables(id int, name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘ ‘ LINES TERMINATED BY ‘\n‘ STORED AS TEXTFILE;
其中TERMINATED BY ‘ ‘指定了数据分隔符是一个空格
创建一个新表,结构与其他一样
hive> create table new_table like testUser;
2、创建分区表
hive> create table logs(ts bigint,line string) partitioned by (dt String,country String)ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘ ‘ LINES TERMINATED BY ‘\n‘ STORED AS TEXTFILE;
加载分区表数据:
hive> load data local inpath ‘/home/test.txt‘ into table logs partition (dt=‘2017-07-20‘,country=‘GB‘);
标签:基本操作 logs file use str int field lin store
原文地址:http://www.cnblogs.com/royfans/p/7212646.html