1.内部表转外部表
alter table temp.app_user_stage SET TBLPROPERTIES('EXTERNAL'='true');
2.外部表转内部表
alter table temp.app_user_stage SET TBLPROPERTIES('EXTERNAL'='false');
3.增加表分区
alter table temp.app_user_stage add partition(pt=20210701);
alter table dtwarehouse.ods_nps_dealer add if not exists partition(pt=${pt}) location '/user/hive/warehouse/ods/amdlr/ods_nps_dealer/pt=${pt}'
4.查看hive函数的详细信息
desc function extended aes_encrypt;
5.建表语句路径和分区路径不一致时,查询分区路径方法
表路径:
/user/hive/dtwarehouse/ods/vehicle/ods_vehicle_tb_weak_binded
分区挂载文件路径:
/user/hive/warehouse/ods/vehicle/ods_vehicle_tb_weak_binded/
describe formatted dtwarehouse.ods_vehicle_tb_weak_binded partition (pt=20210508)
6.hive添加字段
alter table ods_rdp_tt_dealer add columns(parent_org_id string);
7.修改表名
alter table table_name RENAME TO new_table_name
8.修改列名
ALTER TABLE 表名 CHANGE 旧字段 新字段 类型;
alter table dtwarehouse.app_temp change dat dta string;
9.最近一年时间
select date_add(date_format(current_date(),'yyyy-MM-dd'),-365);
10.select * 有数据,但是count(*) 没有数据
analyze table 表名 partition(pt=20210722) compute statistics;
11.Linux下移动文件命令
(将a.log文件移动到当前目录下的log文件夹下)
mv a.log ./log/
12.向分区表插入一条数据
insert into cdp.app_toc_task_monitor partiton (pt=20210802) (app_name,created_time,end_time,real_amount) values('$app_name','$created_time','$end_time','$real_amount')
4299

被折叠的 条评论
为什么被折叠?



