hive common operation commands
1. Date type
Get the current time yyyy-MM-dd HH:MM:ss
相关样例: select from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss')
Date format conversion yyyyMMdd mutual conversion yyyy-MM-dd
select from_unixtime(unix_timestamp('20171205','yyyyMMdd'),'yyyy-MM-dd') 结果:2017-12-05
select from_unixtime(unix_timestamp('2017-12-05','yyyy-MM-dd'),'yyyyMMdd') 结果:20171205
Specific date function introduction
获取当前时间戳 : unix_timestamp()
将时间戳 转换格式 :from_unixtime('时间戳','YYYY-MM-dd HH:mm:ss')
将日期转化成时间戳 日期格式必须是 yyyy-MM-ddHH:mm:ss 转换失败返回0 : unix_timestamp('')
2. Commonly used DML statements
Add/delete specific partition value
Delete: alter table table_name drop partition (dt='XXX')
add:alter table table_name add partition (dt='XXX')
Add/remove fields
Add: alter table table_name add columns(age int)
Delete: Important (There is no delete field operation in hive, you need to add all the fields that need to be used newly) This logic will only retain the id except the partition field. The two fields of sex are important: the operation will not delete the partition field!!!
alter table table_name replace columns (id string,sex int)
3. Change the command in the command line to exit
!quit