Updating unique id column for newly added records in table in hive

荒凉一梦 提交于 2019-12-13 20:14:55

问题


I have a table in which I want unique identifier to be added automatically as a new record is inserted into it. Considering I have column for unique identifier already created.


回答1:


hive can't update the table but you can create a temporary table or overwrite your first table. you can also use concat function to join the two diferent column or string. here is the examples

function :concat(string A, string B…)  
return: string  

hive> select concat(‘abc’,'def’,'gh’) from dual;  
abcdefgh  

HQL &result

insert overwrite table stock select tradedate,concat('aa',tradetime),stockid ,buyprice,buysize ,sellprice,sellsize from stock;
20130726    aa094251    204001  6.6 152000  6.605   100
20130726    aa094106    204001  6.45    13400   6.46    100


来源:https://stackoverflow.com/questions/45491829/updating-unique-id-column-for-newly-added-records-in-table-in-hive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!