ROW_COUNT函数解决了人大金仓数据库KingbaseES 执行语句影响的数据行数计数问题

ROW_COUNT函数解决了金仓数据库KingbaseES执行语句影响的数据行数计数问题

关键字

ROW_COUNT、影响行数、mysql、计数

问题描述

应用开发端直接通过调用函数方式获取某条语句影响的数据行数。

问题分析

缺少简单易用的函数接口。

解决方案

使用ROW_COUNT函数获取上一条语句影响的数据行数。注:该函数仅在KES MySQL模式支持。

sql 复制代码
drop table if exists test_t1,test_t2;

create table test_t1(id int,name varchar(20));

insert into test_t1 values(1,'t1'),(2,'t2'),(3,'t3'),(4,'t4'),(5,'t5'),(6,'t6');

create table test_t2(id int primary key,name varchar(20));

insert into test_t2 select * from test_t1;

--插入数据,键值不冲突,返回影响行数1

replace into test_t2 values(7, 't7'); select row_count();

--插入数据,键值冲突,返回影响行数2(先删除原数据,再插入新数据)

replace into test_t2 values(7, 't7'); select row_count();

--查询数据,返回影响行数为-1(查询语句不影响数据,默认返回-1)

select * from test_t1 where id=7;select row_count();

--删除语句,返回影响行数7

delete from test_t2;select row_count();

参考资料

《KingbaseES SQL语言参考手册》

相关推荐
寻找优秀的自己3 分钟前
Go整合Redis2.0发布订阅
开发语言·后端·golang
考虑考虑31 分钟前
Hibernate级联错误
spring boot·后端·spring
初次见面我叫泰隆42 分钟前
Golang——5、函数详解、time包及日期函数
开发语言·后端·golang
FungLeo1 小时前
一步一步配置 Ubuntu Server 的 NodeJS 服务器详细实录——3. 服务器软件更新,以及常用软件安装
服务器·数据库·ubuntu
厚衣服_31 小时前
第十一篇:MySQL 在分布式系统中的一致性保障与中间件实践
数据库·mysql·中间件
neoooo1 小时前
MySQL中三层B+树索引的数据存储容量解析
后端·mysql
武子康1 小时前
大数据-02-Hadoop集群 XML配置 超详细 core-site.xml hdfs-site.xml 3节点云服务器 2C4G HDFS Yarn Map
大数据·后端
汤姆yu1 小时前
基于springboot的运动员健康管理系统
java·spring boot·后端
老纪的技术唠嗑局1 小时前
OceanBase 中的身外身法 —— Auto DOP(自适应并行)使用技巧分享
数据库·mysql
ak啊2 小时前
域名系统(DNS)
运维·前端·后端