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‘);
时间: 2024-09-29 22:07:52