腾讯云数据仓库 TCHouse-P update 语句

“`sqlupdate tbase set nickname =’Hello TBase’ where id=1update tbase set nickname = ‘Good TBase’ where nickname is null。

相关产品
腾讯云数据仓库 TCHouse-P 产品页,含版本规格、价格与购买入口。

一、单表更新

条件表达方法

查询结果:

select * from tbase;

id nickname
2 TBase 好
1 Hello TBase
3 Good TBase

分布键不能更新:

update t2 set f1=1 where f2=1;

错误信息:

ERROR: Distributed column "f1" can't be updated in current version

二、多表关联更新

update tbase set nickname ='Good TBase' from t_appoint_col where t_appoint_col.id=tbase.id;

查询结果:

select * from tbase;

id nickname
2 TBase 好

三、返回更新的数据

update tbase set nickname = nickname where id = (random()*2)::integer returning id, nickname;

返回结果:

id nickname
2 TBase 好

四、多列匹配更新

update tbase set ( nickname , age ) = ( 'TBase 好' , (random()*2)::integer );

查询结果:

select * from tbase;

id nickname age
1 TBase 好 2
2 TBase 好 0

五、Shard Key 不允许更新

update tbase set id=8 where id=1;

错误信息:

ERROR: Distribute column or partition column can't be updated in current version

赞 (0)
上一篇 4天前
下一篇 4天前