欢迎投稿

今日深度:

hive创建表,

hive创建表,


(1)创建(内部)表

hive> create table table01(ts bigint,line string) ;

(2)创建一个新表,复制表结构和数据

hive> create table table02 as table01;

hive> create table table02 as select * from table01 limit 10;

(3)创建分区表

hive> create table table03(ts bigint,line string) partitioned by (dt string);

增加分区 hive> alter table table03 add partition(dt='2018-04-22');

删除分区 hive>alter table table03 drop IF EXISTS partition(dt='2018-04-22');

(4)展示所有表

hive>show tables;

(5)显示表的结构信息

hive>describe table01;

(6)展示表中有多少分区

hive> show partitions table03;

(7)显示所有函数

hive> show functions;

(8)更新表的名称

hive> alter table table01 rename to table001;

(9)删除表

 

hive> drop table table001;

(10)删除表中数据,但要保持表的结构定义

hive> dfs -rmr /user/hive/warehouse/table001;

--------------------------------------------------------------

(11)创建parquet格式表

create external table parquet_test
(
id    decimal(38,0),
code    string,
money    decimal(38,0)
) COMMENT 'parquet测试'
stored as parquet
location '/user/lhx/hive/parquet_test'

#插入NULL行

insert into done_test values(1,2,3,NULL,NULL,NULL)

www.htsjk.Com true http://www.htsjk.com/hive/39836.html NewsArticle hive创建表, (1)创建(内部)表 hive create table table01(ts bigint,line string) ; (2)创建一个新表,复制表结构和数据 hive create table table02 as table01; hive create table table02 as select * from table01 lim...
相关文章
    暂无相关文章
评论暂时关闭