*命令wiki超链接:*https://cwiki.apache.org/confluence/display/Hive/LanguageManual
创建
-
1.创建新表
create table t_hive ( a int , b int , c int) row format delimited fields terminated by '\t';
-
2.创建分区表
drop table if exists t_hft; create table t_hft( securityid string, tradetime string, preclosepx double ) partitioned by (tradedate int) row format delimited fields terminated by ',';
-
3.创建视图
create view v_hive as select a,b from t_hive;
删除
-
删除数据库(级联删除)
drop database if exists db_name;
-
删除表
drop table if exists tbname ;
-
删除表数据
truncate table tablename;
-
修改表名
alter table tbname rename to newtbname
-
删除分区数据
alter table dbname.tablename drop if exists partition (dtd='20180724');
查询
-
查看数据库信息
desc database extended dbname;
-
模糊查询表名
show tables '*t*';
-
查询表结构
desc formatted table_name
-
查看表分区
show partitions tbname;