HIVE SQL经常使用的技巧

1:展示一个表的分区

show partitions dw_htlbizdb.userlibrary_new

结果:

2: 查看一个job的原代码

其中:d为分区,id为你要查看的job的id

select * from ods_zeus.ods_zeus_job

where d = '2017-09-28'

and id = 16476

结果:job的代码在script中

3:修改一个表中某个字段的描述

alter table fct_user_ctag_today CHANGE COLUMN rpt_tag rpt_tag int comment '1新客,2新转老,3新注册,5老客';

4:删除分区

use dw_htlbizdb;

alter table fry_hhm_model_uid_dimensions_nofilling_value drop partition (d='${Last_Week}');

5:修改表名

use dw_htlbizdb;

ALTER TABLE detail_reserve_jiankong_new RENAME TO detail_reserve_jiankong

6:添加一列

use dw_htlbizdb;

alter table tmp_htldetailpage_hotel_1234 add columns (price_deduc string comment '页面价格');

7:修改列的属性

use olap_htl_majicdb;
alter table ceq_hotel_order_booker_insights change column ordpersons ordpersons int;

8:添加分区

use dw_htlbizdb;

alter table tmp_htldetailpage_hotel_1234 add partition(d=‘2016-10-10’);

9:删除表

use dw_htlbizdb;

drop table detail_viewdetails_jiankong;

10:根据一个已存在的表,新建一个结构一样的表

use dw_htlbizdb;

CREATE TABLE tmp_hotelInlandList_tracelogsdk_hide_1

LIKE hotelInlandList_tracelogsdk_hide;

猜你喜欢

转载自blog.csdn.net/Jarry_cm/article/details/81777168