首页 > 数据库 >mysql,row_count()

mysql,row_count()

时间:2022-12-05 18:55:13浏览次数:90  
标签:count rows affected value mysql statements row

ROW_COUNT()

ROW_COUNT() returns a value as follows:

  • DDL statements: 0. This applies to statements such as CREATE TABLE or DROP TABLE.

  • DML statements other than SELECT: The number of affected rows. This applies to statements such as UPDATEINSERT, or DELETE (as before), but now also to statements such as ALTER TABLE and LOAD DATA.

  • SELECT: -1 if the statement returns a result set, or the number of rows “affected” if it does not. For example, for SELECT * FROM t1ROW_COUNT() returns -1. For SELECT * FROM t1 INTO OUTFILE 'file_name'ROW_COUNT() returns the number of rows written to the file.

  • SIGNAL statements: 0.

For UPDATE statements, the affected-rows value by default is the number of rows actually changed. If you specify the CLIENT_FOUND_ROWS flag to mysql_real_connect() when connecting to mysqld, the affected-rows value is the number of rows “found”; that is, matched by the WHERE clause.

For REPLACE statements, the affected-rows value is 2 if the new row replaced an old row, because in this case, one row was inserted after the duplicate was deleted.

For INSERT ... ON DUPLICATE KEY UPDATE statements, the affected-rows value per row is 1 if the row is inserted as a new row, 2 if an existing row is updated, and 0 if an existing row is set to its current values. If you specify the CLIENT_FOUND_ROWS flag, the affected-rows value is 1 (not 0) if an existing row is set to its current values.

The ROW_COUNT() value is similar to the value from the mysql_affected_rows() C API function and the row count that the mysql client displays following statement execution.

标签:count,rows,affected,value,mysql,statements,row
From: https://www.cnblogs.com/whatsoever/p/16953177.html

相关文章

  • 生产环境mysql主从同步中断引发的启迪
    迁移背景:生产环境mysql主从同步中断,因中断时间太久、数据量太大,所以计划通过云平台的磁盘克隆功能实现数据全量同步。环境说明:主库:192.168.12.76盘名:/dev/mapper/mysql-da......
  • LeetCode: 315. Count of Smaller Numbers After Self
    LeetCode:315.CountofSmallerNumbersAfterSelf题目描述Youaregivenanintegerarraynumsandyouhavetoreturnanewcountsarray.Thecountsarrayhast......
  • mysql批量修改数据
    UPDATEmeteo_forecast_itemSETforecast_path=REPLACE(forecast_path,'/data/jjj-smart-grid','/home/jjj-smart-grid/data')UPDATEqiyun_station_sequentialSET......
  • MySQL窗口函数介绍详情
    一、窗口函数基本点(一)定义窗口的概念非常重要,它可以理解为记录集合,窗口函数也就是在满足某种条件的记录集合上执行的特殊函数。对于每条记录都要在此窗口内执行函数,窗口......
  • 1.1初始化配置MYSQL服务器
    /*初始配置服务器,需先根据操作系统下载MicrosoftAccess2010数据库引擎AccessDatabaseEngine_X64.exe(https://www.microsoft.com/zh-cn/download/confirmation.aspx?id......
  • 【转载】详解mysql插入数据后返回自增ID的七种方法_java
    引言mysql和oracle插入的时候有一个很大的区别是:oracle支持序列做id;mysql本身有一个列可以做自增长字段。mysql在插入一条数据后,如何能获得到这个自增id的......
  • MySQL的零拷贝技术
    1.需要了解Buffer与cache的区别Bbuffer与Cache非常类似,因为它们都用于存储数据数据,被应用层读取字节数据。在很多场合它们有着相同的概念:首先从翻译上,Buffer应该翻译......
  • mysql8 postgresql 递归查询一条SQL支持帝国查询
    创建表点击查看代码createtabletb(idvarchar(3),pidvarchar(3),namevarchar(10));insertintotbvalues('002',0,'浙江省');insertintotbvalues......
  • mysql中游标的运用
    【背景】  最近项目中应对实际情况的需求,又修改了主业务,导致表结构设计不合理,之后又修改了表结构,但是表结构修改之后历史数据需要升级,来适应新的表结构的一系列增删改......
  • docker 安装mysql8
    1.环境准备1.centos7  2.安装包下载1.百度网盘下载链接:https://pan.baidu.com/s/1AfRUkiXD9Oee1hA5az9SXg提取码:gs7b 2.版本说明此安装包为dockermysql8......