1. 程式人生 > >2、hive的基本操作

2、hive的基本操作

like -s txt code del class ext data 數據

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‘);
 

  

 

2、hive的基本操作