天天看點

使用hive的常用指令語句

使用hive的常用指令語句

1、linux進入 hive指令行

beeline

2、檢視所有表

show tables;

3、檢視是否是分區表

show partitions tableName;

4、檢視表前幾條記錄

select * from tableName limit 10;

5、檢視表某一分區資料

select * from tableName where 分區字段=分區 limit 10;

6、建立表(例子)

create table if not exists tableName(

name string,

age int,

sarlar bigint

)row format delimited fields terminated by '\t' stored as textfile;

7、模糊查找表

show tables like '*tableName*';

8.建立視圖

create view viewName select * from tableName;

9.删除表

drop table tableName;

10.就文本資料導入hive表

load data local inpath '/usr/data/students.txt' into table studentTable partition(classId=1)

11.建立帶有分區的hive表

create table if not exists tb_hive_table(

name string,

age int

) partitioned by(ad string);