专栏名称: 数据分析与开发
伯乐在线旗下账号,分享数据库相关技术文章、教程和工具,另外还包括数据库相关的工作。偶尔也谈谈程序员人生 :)
目录
相关文章推荐
KubeSphere云原生  ·  OceanBase 上架 ... ·  5 小时前  
数据中心运维管理  ·  什么是数据中心布线以及主要布线标准? ·  昨天  
AustinDatabases  ·  云数据库产品应改造PostgreSQL逻辑复 ... ·  14 小时前  
AustinDatabases  ·  泉城济南IvorySQL 2025 ... ·  昨天  
AustinDatabases  ·  泉城济南IvorySQL 2025 ... ·  昨天  
数据中心运维管理  ·  2025年度国家数据中心节能监察任务清单印发 ... ·  3 天前  
51好读  ›  专栏  ›  数据分析与开发

用 Phoenix 通过 SQL 语句更新操作 HBase 数据

数据分析与开发  · 公众号  · 数据库  · 2017-02-03 21:24

正文

请到「今天看啥」查看全文


10 );


Phoenix 中操作如下:




上图看到已经新增了列sex,每行的默认值为 null ,那么怎么样修改这些值呢?


4、 更新表数据 ,标准的sql 如下:


update test .Person set sex = '男' where IDCardNum = 100 ;

update test .Person set sex = '女' where IDCardNum = 101 ;

update test .Person set sex = '男' where IDCardNum = 103 ;


Phoenix中不存在update的语法关键字,而是upsert ,功能上替代了Insert+update,官方说明为:


UPSERT VALUES


Inserts if not present and updates otherwise the value in the table. The list of columns is optional and if not present, the values will map to the column in the order they are declared in the schema. The values must evaluate to constants.


根据介绍,只需要在upsert语句中制定存在的idcardnum即可实现更新,在 Phoenix 客户端中操作如下:




5、复杂查询,通过Phoenix可以支持 where、group by、case when 等复杂的查询条件,案例如下:




where + group by 语句例子:


jdbc : phoenix : 10.35.66.72 > select sex , count ( sex ) as num from test .person where age > 20 group by sex ;

+------------+------------------------------------------+

| SEX | NUM |

+------------+------------------------------------------+

| | 4 |

+------------+------------------------------------------+


case when 的例子:


0







请到「今天看啥」查看全文