hive的建表方式:
方式一:
create table if not exist table_name(
......
);
comment 'description of the table'
tblproperties('cretor'='me','create_at'='2012-01-02 10:00:00',...)
LOCATION '/user/hive/warehouse/mydb.db.table_name'
方式二:
create table if not exists table_name1 like table_name;
hive的插入数据的方式:
Hive的分区操作:
分区修改:
Alter table_name partition (date='201801') rename to partition(date='201802')
删除分区:
alter table login Drop if exists partition(date='201801')
添加分区:
alter table table_name add id not exists partition(date='201803') location '/user/hadoop/warhouse/table_name=dt=201803'
HIve的一些基本命令
查看表的分区
show partitions table_name;
//查看特定分区
show partitions table_name partition(date='20200101')
//数据拷贝
hadoop distcp /data/log_message/ node01://ourbucket/logs/
//删除hdfs的数据
hadoop fs -rmr /data/log_message/
//定义存储格式
stored as orc;
//修改列信息
alter table log_message
change columns hms hours_minutes_second INT
comment 'the hours minutes and seconnds part of the timestamp'
alter severity;
//增加列
alter table log_message add columns(app_name String);