Hive建立表常見的命令
1、建立新表
create table student_hive (name string, sex string ,age int) row format delimited fields terminated by '\t';
2、匯入資料student_hive.txt到student_hive表
load data local '/home/hairui/student_hive.txt' overwrite into table student_hive;
3、正則匹配表明
show tables 'student';
4、增加一個欄位
alter table student_hive add columns (new score int);
5、重命令表名
alter table student_hive rename to student_hivehive;
6、從HDFS載入資料
load data inpath '/home/hairui/warehouse/student/student_hive.txt' overwrite into table student_hivehive;
7、從其他表匯入資料
insert overwrite table student_hive select * from student;
8、建立表並從其他表匯入資料
create table student_hive as select *from student;
9、僅複製表結構不匯入資料
create table student_hive like student;
10、通過hive匯出到本地檔案系統
insert overwrite local directory '/tmp/student_hive' select * from student;
11、hive查詢HiveQL
from (select name,sex as sex from student_hive) student select student.name, student.sex;
select name,sex from hive limit 2;