更新配置单元中表中新增记录的唯一标识列 [英] Updating unique id column for newly added records in table in hive

查看:68
本文介绍了更新配置单元中表中新增记录的唯一标识列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,我想要在插入新记录时自动添加唯一标识符。考虑到我的列已经创建了唯一标识符。

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.

推荐答案

hive无法更新表,但可以创建临时表或覆盖你的第一张桌子。
您也可以使用 concat 函数来加入两个不同的列或字符串。
这里是例子

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

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

这篇关于更新配置单元中表中新增记录的唯一标识列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆